I'm writing a program that reads all the lines of an input file. I'm required to use a while loop to read each line of the file, a for loop to process each line, and if statements involving boolean operators in order for me to analyze each character. So far, i have a while loop to read all the lines in a file that looks like this:
while(getline(infile,line))
{
cout << line << endl;
}
I don't think i am supposed to hard code the "cout << line << endl;" since i have to process the line using a for loop. Which I am stuck on how to use a for loop.
Also, i need to print out the words "Line 1", "Line 2", "Line 3", etc. I tried using the increment but its reading the 1st line in the file as different lines.
Line 1: (First line in the file)
Line 2: (Second line in the file)
Line 3: (Third line in the file)
Line 4: (Fourth line in the file)
However, the first line in the file has 4 lines but i just want to consider it as Line 1.