I have here a problem...
i have a notepad containing values such as:
tom,a1001,1
charles,1002,2
I used getline() and used the delimiter comma to separate them and store it in line variable..
my problem is that how can i store the delimited strings from line variable to any different variables..
ex .tom should be stored in employee variable or a1001 should be stored in idnumber variables.
Here's my lacking code:
#include<iostream>
#include<fstream>
#include<string>
#include<cstdlib>
using namespace std;
void main()
{
string line;
string filename="employee.txt";
ifstream myfile;
myfile.open(filename.c_str());
if(myfile.fail())
{
cout<<"Unable to open file named"<<filename<<endl;
exit(1);
}
while(myfile.good())
{
getline(myfile,line,',');
cout<<line;
}
}
Please help me..