I would like to write a program that read characters from a file and display them with two spaces between each character.
However, I am limited to 10 characters per line.
How could I make the program return to a new line every 10 characters?
// OUTPUT CHARACTERS FROM FILE
cout << "Characters read from file are: " << endl;
inFile.get(textWritten);
while (inFile) {
if (textWritten == SPACE) cout << " ";
cout << textWritten << " ";
inFile.get(textWritten);
}
You can do something like this:
int charCount = 0;
//inside the while-Loop
if(charCount == 10) {
cout << "\n";
charCount = 0;
}
//if it is a new character
charCount++;