my objective is to simply read in characters and store it in a multidimensional character array.
file format .. 50 lines of 80 characters
example
155157JOHN Q. PUBLIC 00015787
155238HELEN GONE 00015687
trying to read from a employee.dat file until the end of file, but keeps on getting segmentation error.
int main()
{
ifstream data;
char string[80];
char s1[50][80];
int i=0;
data.open("c:/employee.dat",ios::in);
if(!data)
{
cerr << "file cannot be opened! " << endl;
exit(1);
}
while(!data.eof())
{
data.get(string,80,'\n');
strcpy(s1[i],string);
cout << s1[i] << endl;
i++;
}
data.close();
return(0);
}



LinkBack URL
About LinkBacks



That way everyone can read the code