hello,

i am new to c programming and i have just begun some basic work. i am trying to read three numbers from a line, that's separated by a space like, "11 32 43", in a separate text file and i am trying to read each number and get the sum to print. unfortunatley i'm not too sure about how to go about reading the numbers... here's a snippet...

i'm afraid that using the "getchar()" will not work with double digit numbers. i was just wondering what is the best way to go about reading the numbers, per line. i get the corresponding ascii number, but i need to change that to an integer value, for calculation.Code:int linenum = 0; // counting from 1 char *ch; // store each input character here int num; while( ( *ch = getchar() ) != EOF ) { if ( !( (*ch == 32) || (*ch == '\n') ) ) { num = atoi(ch); printf("%d" , num); } }

thank you.