From: Aurimas Č. <au...@gm...> - 2009-01-20 10:38:29
|
Hi, > Hi,all > I have the codes: > #include <stdio.h> > int > main(int argc,char **argv) > { > int num = 1; > FILE *f; > f = fopen("e:\\code\\fscanf.txt","rb"); > int i; > for (i = 0; i < 4; ++i) > { > fscanf(f,"%d",&num); > printf("%c",num); > } > fclose(f); > return 0; > } > Compiled it: gcc -o fscanf.exe fscanf.c > Run it:fscanf > my fscanf.txt has:abcd > why it dosn't work properly to output the content of fscanf.txt. Why do you read %d, while write %c? Also, %c is used with chars, not ints. -- Aurimas |