GoAskAlice
Programmer
Gosh, this sounds so easy! But, I am having serious problems.
I wrote a file using fwrite to record 9 number sequences of 8 digits each in length. No seperators, just a long line of digits went into the file.
Now, I want to pull a single digit from the file using fread but it really wont let me do it.
I have set up an array;
int a[8];
to record 8 digits from the file.
I use;
readcount = fread(a,8,8,fp);
to read the numbers from the file.
This however, fills each array with 8 digit numbers. I have tried several different ways of doing this, such as changing the number 8 to 1, and so on, and all I get is garbage output.
I mean, I just want to be able to read 8 digits at a time from the file and have each digit indexed in an array so I can process it.
It really has got me because I also tried fgetc without any success...
Can some one PLEASE help!
I wrote a file using fwrite to record 9 number sequences of 8 digits each in length. No seperators, just a long line of digits went into the file.
Now, I want to pull a single digit from the file using fread but it really wont let me do it.
I have set up an array;
int a[8];
to record 8 digits from the file.
I use;
readcount = fread(a,8,8,fp);
to read the numbers from the file.
This however, fills each array with 8 digit numbers. I have tried several different ways of doing this, such as changing the number 8 to 1, and so on, and all I get is garbage output.
I mean, I just want to be able to read 8 digits at a time from the file and have each digit indexed in an array so I can process it.
It really has got me because I also tried fgetc without any success...
Can some one PLEASE help!