Simple question:
If i have a line in an input file that looks looks like:
Hello#Great#Day#Today
how can I scan in each word individually as its own array, in other words tell C to stop scanning when it reaches the # character and then go in the next iteration of the loop to scan the next word as a separate array?
This is assuming you are reading through stdin
. Definitely take a look at @Whoz kick start approach as well (very similar to this).
What you would want to do is create a dynamic array and populate it with every byte read through stdin
. You would then want to create an array of character pointers that will point to the first character in every "word", where you define a word as every character before a '#'
character (delimiter). You would then iterate through that array of characters and populate the array of character pointers with the memory addresses of the first character in each word.