what I am needing to do is read a character from a file into a structure member. I thought it would be simple enough but fscanf, I guess just works for strings. I commented out tons of stuff and put a printf statement after every fscanf and the character line is where it falls apart. The preceding members are strings and after hours of testing everthing else I finally came to the conclusion the fscanf does not return anything that fits neatly into a char.
Code:
typedef struct
{
char mem1[10];
char mem2[10];
char mem3[10];
char mem4;
int mem5;
}struct_a
FILE *fout;
fscanf(fout, "%s", struct_a.mem1);
fscanf(fout, "%s", struct_a.mem2);
fscanf(fout, "%s", struct_a.mem3);
fscanf(fout, "%c", struct_a.mem4); /*this is the line that's a problem*/
fscanf(fout, "%d", struct_a.mem5);/*haven't tested to this line yet either*/
I was hoping to be able to continue using fscanf so as not to lose my place in the file.
Hopefully the preceding is enough to give you an idea of what I am doing without weighing the post down with a bunch of extra stuff.