Can i do this? it does not seem to work....
class EmployData
{
private:
getData();
getFile();
//closeFile(); //not created yet
ifstream in_file; //function header?
char Data[546]; // create an array for data from file
public: //temporary so this compiles
void showData(void);
};
EmployData::getFile()
{
in_file.open("SEmploy.txt"
cout << "in getFile" << endl;
if (in_file.fail())
{
cout << "the file failed to OPEN please check the file
and try again. " << endl;
exit(1);
}
}
EmployData::getData()
{
//ifstream SEmploy.txt;
//char Data[546];
in_file.get(Data, 546);
char strNum[6], fstName[50], lstName[50];
const char toksep[] = " \n";
int nNum;
char *ptr;
cout << "in getData" << endl;
ptr = strtok(Data, toksep);
strcpy(strNum, ptr);
nNum = atoi(strNum);
ptr = strtok(NULL, toksep);
strcpy(lstName, toksep);
ptr = strtok(NULL, toksep);
strcpy(fstName, toksep);
}
void EmployData::showData(void)
{
cout << Data[2] << endl;
}
I'm really only concerned as to why I can't seem to get the file open...
class EmployData
{
private:
getData();
getFile();
//closeFile(); //not created yet
ifstream in_file; //function header?
char Data[546]; // create an array for data from file
public: //temporary so this compiles
void showData(void);
};
EmployData::getFile()
{
in_file.open("SEmploy.txt"
cout << "in getFile" << endl;
if (in_file.fail())
{
cout << "the file failed to OPEN please check the file
and try again. " << endl;
exit(1);
}
}
EmployData::getData()
{
//ifstream SEmploy.txt;
//char Data[546];
in_file.get(Data, 546);
char strNum[6], fstName[50], lstName[50];
const char toksep[] = " \n";
int nNum;
char *ptr;
cout << "in getData" << endl;
ptr = strtok(Data, toksep);
strcpy(strNum, ptr);
nNum = atoi(strNum);
ptr = strtok(NULL, toksep);
strcpy(lstName, toksep);
ptr = strtok(NULL, toksep);
strcpy(fstName, toksep);
}
void EmployData::showData(void)
{
cout << Data[2] << endl;
}
I'm really only concerned as to why I can't seem to get the file open...