scanf - Why can't I change string to integer -
i'm new here
i've been trying input txt file , change data integer got stuck here.
#define max_len 100 #define max_num 10 int main(int argc, char* argv[]){ file *in; in=fopen(argv[1],"r"); char innum[max_len]; int number=11; int i=0; while(eof!=fscanf(in,"%s\n",innum)) { number=atoi(innum); printf("%s %d %d\n",innum,i,number); i++; } return 0; }
the input is
123231 1235992 513234
but result is
123231 0 0 1235992 1 1235992 513234 2 513234
i couldn't find reason why first line input changes 0.... please me
Comments
Post a Comment