Search code examples
c++text-filesfstream

Reading text file - C++


If my text file had something like:

111 Bob
222 Jim
333 Joe
444 Mike
555 Gary

I want to read each line and split each line into an ID number and a name in order to plug them into a function. How do I split up each line that is read from a file into two variables?


Solution

  • Read file line by line Answers of this question show how to read a text file line by line. And you can find how to split a string via this question. c++ boost split string