I have a text file filled with some numbers that I would like to read.
My text file looks like this.
1 2 3 5 0
2 5 8 5 0
7 8 6 9 0
I would like to read this text file into this structure:
struct numbers num[]
My struct is defined like this:
struct numbers {
int totalnumbers;
};
The first time this would go into the structure:
1 2 3 5 0
And th second time:
2 5 8 5 0
And so on unitl the end of the file.
Thank very much in advance for any help.
My advice is to refer to your course notes/textbook and start writing code.
Honestly you will learn nothing by taking a completed program from the answers here.
in the file to the console (hint
fopenandfgets. . . I think, it’s been a while).strtok)strings) to integers (hint prefer
strtoloveratoi)Programming is all about divide & conquer, which is really just solving the little problems one at a time until the big problems are solved.
Hope this helps.