+ 2

How can i get to read a .txt file that has a list of names and ages. Example Angel 76, Joe 67, Paul 71.

I'm trying to learn at my 76 years how to program little stuff. any help will be grateful

31st Aug 2017, 4:06 AM
Angel Cosme
Angel Cosme - avatar
1 Respuesta
+ 1
#include <iostream> #include <fstream> #include <string> using namespace std; void main () { string STRING; ifstream infile; infile.open ("names.txt"); while(!infile.eof) // To get you all the lines. { getline(infile,STRING); // Saves the line in STRING. cout<<STRING; // Prints our STRING. } infile.close(); system ("pause"); }
27th Sep 2017, 12:29 AM
Jeff Shipton
Jeff Shipton - avatar