Reading from file with specific widths.
I have an input file that has 3 columns. The first column includes alphanum special characters and spaces as well. It looks like this:
Here is my code that I wrote to read such files, but obviously, having spaces in the first column makes this code with fscanf inapplicable. I know the width of every column, so I know the number of characters to read. Any suggestions on how I could go about this? Thanks!
@ED#@ 11 AAA
!@ R$ 22 BBB
!@EDF 33 CCC
EV? % 44 DDD
int main(int argc, char *argv)
FILE *in, *out;
char one, two, three;
in = fopen(argv,"r");
out = fopen(argv,"w");
while(fscanf(in,"%s %s %s ", one, two, three) != EOF)
printf("Line %d: One:%s Two:%s Three:%s\n", i++,one, two, three);
//fprintf(out,"insert %s %s%s\n", one, two, three);