Image

Imagevalera wrote in Imagecpp

for some reason, if the strcmp(buffer,"") condition isn't there, it reads one more line than there is in report.txt. it's like it sees something that cat -n and wc -l don't notice... but that's where strcmp line comes in handy. does anyone know why it would do this?

#include <fstream>

using namespace std;

int main(){
        char buffer[1024];
        int counter=1;
        ifstream inFile("report.txt");
        ofstream outFile("report2.txt");


        while( ! inFile.eof() ) {       
                inFile.getline(buffer,1024);
                if(strcmp(buffer,"")){
                        outFile <<  counter++ <<") <a href=\"/" << buffer << "\">" << buffer << "</a><br>\n";
                        }
        } 
        inFile.close();
        outFile.close();
        return 0;
}