Help with reading/writing integers in a specific way into/from a file!!
Hi!
I am trying to learn how to read and write integers into a file in severreral rows.
Then I want to read the Integers from each row and put the integers in separate arrays.
Example of how the file looks like after adding integers:
=======================================
1 2 3 4 5...
6 5 4 3 2...
7 78 5 45...
How do I write to put maybe 100 integers in the first row, then the second row and so on???
When I have managed hat I want to read the integers from the first row and put them in a array like this:
[1][2][3][4][5] without the space betwwen each integer!
Here I also don't now how I start reading the integers from the second row to put the integers in another array.
So far I have tested to put 2 integers in the first row. Is it necessary to fprintf a space after each integer or is there another way??
int main(int argc, char *argv[])
{
FILE *myFile = fopen("txtFile.txt", "w");
fprintf(myFile, "13");
fprintf(myFile, " ");
fprintf(myFile, "4\n");
fclose(myFile);
system("PAUSE");
return 0;
}
Appreciate any help!
PS, how do I align the code so it gets nicer?? THe link from the faq is dead.