Greetings!
I am a newbie in c++.Now i have a problem.With my source code..What should i do..This is my problem...
This program tries to retrieve datas from a notepad, named employee.txt,consisting of employees data,
Such as:idnumber,employee name,salary grade.
Ex. A1001,John Davidson,1
A1002,Andrew Jackson,2
I use getline to delimit the string...
Now my problem is how am i going to assign the delimited string into different arrays??
Ex. A1001 and A1002 is a assigned to an array named idnumber.
John Davidson and Andrew Jackson is assigned to an array named emplname..
Now can you give me the solution to my problem??
Please help..
Can you give me a sample code?
#include<fstream>
#include<iostream>
#include<string>
#include<cstdlib>
using std::cout;
using namespace std;
void main()
{
int x=0;
string filename="employee.txt";
fstream empfile;
empfile.open(filename.c_str());
if(empfile.fail())
{
cout<<"Unable to open file: "<<filename<<endl;
exit(1);
}
while(empfile.good())
{
getline(empfile,line,',');//Problem Here...I want the delimited string to be assigned in diff. arrays..
}
}
This post has been edited by no2pencil: 20 March 2012 - 07:59 PM
Reason for edit:: Added code tags

New Topic/Question
Reply



MultiQuote






|