Let say I have this file "inputfile.txt" and the file contains the text below...
First Name: Ron
Age: 40
And I want get the txt after the ": ". For example I would want the input "Ron" and "40" and put it into a class to be stored. How exactly would I do that? This is what I have so far...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
#include <fstream>
#include <stdlib.h>
usingnamespace std;
int main()
{
string inputFile;
cout << "Please enter the file you would like to input: ";
cin >> inputFile;
ifstream fin(inputFile.c_str());
}
I don't know quite how to skip the first part of the text ("First Name: ") and only input the text after that ("Ron")? Also is there any way to do the input stuff in the classes and not in the main function? Basically I want to ask, in the main function, if the user would like to create a person with a first name and age? If the user says yes, then there is a function call to the input class, and the input class takes in the input file, and stores all the input, to be retrieved later.