+ 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
1 Réponse
+ 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");
}