I have same problems with the below code.I try to read from file a destination.
void airplane::readFlight(void)
{
char temp[100];
ifstream f("date.txt");
if(!f)
{
cerr<<"Err";
//exit(EXIT_FAILUARE);
}
f>>nrFlight;
for (int i=0;i<nrFlight;i++)
{
f.getline(temp,99);
destination[i]=new char(strlen(temp)+1);
strcpy(destination[i],temp);
}
f.close();
}
And i get this errors:
invalid conversion from ‘char’ to ‘char*’
initializing argument 1 of ‘char* strcpy(char*, const char*)’
Invalid arguments 'Candidates are:char * strcpy(char *, const char *)
This error appears when i allocate memory and when i try to copy the information. Thx.