Hey there, struggling learning this and first time poster here. Getting pretty aggravated trying to figure out a solution.
Let's say you need to read in some data from a .dat file. The file will start by giving you an arbitrary integer "n"that determines the size of a vertical array or n by n matrix.
For example, if your data file started out formatted like so:
4
labor;metals;plastics;elctrncs
Charlie;Snoopy;Lucy;Linus
BUT, the data file could also have several of these examples in the same data file one after each other where you would need to perform operations on them.
How do I scan in the character strings of data into two single arrays of one name per row?
Example, I want variable1 to be:
labor
metal
plastics
electncs
and variable2 to be:
charlie
snoopy
lucy
linus
When I try a while loop to fscanf to EOF, the %s into the array doesn't know when to stop inputting because it should be stopped based on the size of the first integer.
When I try scanning in with a for loop and counter to play the strings into the storage cells based on i<(integer-1), I only get gibberish or it crashes.
Any thoughts?