Hi guys, just after a bit of advice as to how to go about this problem, not after a solution.
What I have to do is read in a text file and put the characters in it into strings. however, when there is a comma, i need to put it in a new string and i need to ignore whitespace and punctuation.
Probably a bad example, so here's an example:
The dog,sat, on, the.
Would be:
string1: "The"
string2: "dog"
string3: "sat"
string4: "on"
string5: "the"
However, what I don't know is how many characters each string will be.
To do the string allocation, would I have to assign it once I know how many characters there are, i.e: char string1[NO_OF_CHARACTERS]?
I'm assuming my best option would be to use fgetc and putting it in a while function, saying while(!ispunct(fgetc(file)) to ignore the punctuation and doing another one saying while(!isspace) etc...?
Just trying to brainstorm a bit here. Any advice would be very helpful.
Cheers.
What I have to do is read in a text file and put the characters in it into strings. however, when there is a comma, i need to put it in a new string and i need to ignore whitespace and punctuation.
Probably a bad example, so here's an example:
The dog,sat, on, the.
Would be:
string1: "The"
string2: "dog"
string3: "sat"
string4: "on"
string5: "the"
However, what I don't know is how many characters each string will be.
To do the string allocation, would I have to assign it once I know how many characters there are, i.e: char string1[NO_OF_CHARACTERS]?
I'm assuming my best option would be to use fgetc and putting it in a while function, saying while(!ispunct(fgetc(file)) to ignore the punctuation and doing another one saying while(!isspace) etc...?
Just trying to brainstorm a bit here. Any advice would be very helpful.
Cheers.