Question: could someone fix this for me? int fileLoadRead(string filename) { ifstream in(filename.c_str()); if(!in.is_open()) { return -1; } else { int count =0; string line; while(getline(in,line))

could someone fix this for me?

int fileLoadRead(string filename) { ifstream in(filename.c_str()); if(!in.is_open()) { return -1; } else { int count =0; string line; while(getline(in,line)) { count=count+1; } in.close(); return count; } }

could someone fix this for me? int fileLoadRead(string filename) { ifstream in(filename.c_str());

if(!in.is_open()) { return -1; } else { int count =0; string line;

while(getline(in,line)) { count=count+1; } in.close(); return count; } } Write a function

Write a function fileLoadRead that reads a file. The function takes one parameter, the name of the file filename . The function returns the number of lines in the file If the file was not opened successfully, return -1 If the file exists but is empty (contains no non-newline characters), return 0 If the file exists and is not empty, return the number of lines. Include all the lines in your count even those that are blank For Example Given a file called myFile.txt with the following content hola ciao hello hallo the function call fileloadRead"myFile.toxr) would return 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!