Answer to Question #57943 in C++ for mabswhale

Question #57943
How to count number of entries in a txt file ?
1
Expert's answer
2016-02-22T02:37:12-0500
int main() {
int number_of_lines = 0;
std::string line;
std::ifstream inpFile("file.txt");
while (std::getline(inpFile, line))
++numberOfLines;
std::cout << "Number of lines in text file: " << numberOfLines;
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS