how do i count characters after i get words from text

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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
}
Topic archived. No new replies allowed.