i found out how to get each individual word from a text file. Now i am trying to limit each line to a certain number of characters. If the line limit is 10 and the word "string" starts at position 8, i need to make a newline and put "string" on the new line. I want to count characters to control the limit, however i do not know how to count the characters given that i got the words from a text file.
Here is my code so far:
int rearrange(int lineLength, istream& inf, ostream& outf)
{
int charInLine = 0;
const int maxLength = 10000;
getWord(inf, outf);
for(int i = 0; i < maxLength; i++)
{
}
return 0;
}
int getWord(istream &inf, ostream &outf)
{
char sentence[100000];
while(!inf.eof())
{
inf >> sentence;
outf << sentence << " ";
}
return 0;
}