Beispiel #1
0
int main( void )
{
	int i ;
	i = 469;
	 
	int n,x;
	n = 3;
	x = 2;
	
	char ascii[20]={"23132324"};



	binarry_to_ascii( i );

	i = hermite( n, x);
	printf("\n the y is :%d \n",i);

	i = gcd( 24, 16 );
	printf("\n the y is :%d \n",i);


	i=ascii_to_integer( ascii );
	printf("\n the y is :%d \n",i);
	
}
Beispiel #2
0
int main(int argc, char **argv)
{
	int fd;
	int nread;
    int speedcom;
	char buff[512];
    time_t nowtime;
    time(&nowtime);
	printf("%s",asctime(gmtime(&nowtime)));
    //char command[100] = {0x01, 0x03, 0x00, 0x40, 0x00, 0x18, 0x44, 0x14};
    char *command = argv[3];
	fd = OpenDev(argv[2]);
    printf("fd: %u\n", fd);
    printf("open tty: %s\n", argv[2]);
	if (fd>0) {
        speedcom = ascii_to_integer(argv[1]);
        printf("speedcom: %d\n", speedcom);
        set_speed(fd,speedcom);
        printf("open fd: %u\n", fd);
    }
	else {
    	printf("Can't Open Serial Port!\n");
		exit(0);
	}
    if (set_Parity(fd,8,1,'N')== FALSE) {
        printf("Set Parity Error\n");
        exit(1);
    }
    //ioctl(fd, RS4851_C30, 1);
    //printf("writting command: %s\n", command);
    //write(fd, command, sizeof(command));
    //usleep(10000);
    while(1) {  
        //ioctl(fd,RS4851_C30,1);
        //printf("writting command: %s\n", command);
        //write(fd, command, 8);
        //usleep(500000);
        //ioctl(fd,RS4851_C30,0);
   		//usleep(500000);
        //while((nread = read(fd,buff,512))>0)
   		//{
      	//  printf("\nLen %d\n",nread);
      	//  buff[nread+1]='\0';
      	//  printf("\n%s",buff);
        //}
        
        while(nread = read(fd,buff,512)) {
      	    buff[nread+1]='\0';
            //printf("printf %s\n", buff);
            //write(1,  buff, nread);
            //write(fd, buff, nread);
   	 	}
  	}
    close(fd);
    exit(0);
}
int main()
{
    char string[100];

    printf("Boy...Please enter a string and make sure the length \n of the string no more longer than 100 char\n\n");

    gets(string);

    printf("\n\nThe number in the string : %d\n",ascii_to_integer(string));

    return 0;
}
Beispiel #4
0
int main(void) {
    char str[10] = "234";
    int res;
    res = ascii_to_integer(str);
    printf("%d\n", res);
}