Okay, so I'm pretty new at this whole file reading thing, and I'm trying to make it so that the program reads a file, attaches a line number to the beginning of each line, and sends the output to another file. The thing is, there's this error that pops up, and I'm not exactly sure why.
The code that I have is as follows:
Is there something I'm doing wrong? Something I'm missing?
The code that I have is as follows:
Code:
#include <iostream>
#include <fstream>
using namespace std;
int main (void)
{
char c;
int line = 0;
ifstream IS = "hw6b.cpp";
ofstream OS = "hw6boutput.cpp";
while ((c = IS.get()) != EOF)
if ( c == '\n')
{
line++;
OS << line << '.' << '\t' << c;
};
return 0;
}
Comment