i have started writing a program to do a fast sort but on one of my builds an error is coming up and i don't know what exactly it means could you please help.
int main(void){
char c[k];
cout<<"Please enter the input filename:"<<endl; // read in the input and output filenames
cin>>c;
char h[k];
cout<<"Please enter the output filename:"<<endl;
cin>>h;
ifstream in(c);
if (!in){
cerr<<"Failed to open input file"<<c<<endl;
exit(1);
}//close if
int t=0, f;
char tempX[a], tempY[a]; // count the number of records in the file by reading them in
int tempZ;
while (in>>tempX>>tempY>>tempZ){
if (t<MAX){
t+=1;
}
}
f=t;
in.close(); // reset the input file status after reading to the end
in.seekg(0); // rewind the file using seekg()
friends* best= new friends [f]; // create an array (of structs) to hold all persons in the file
while(in){ // read the data for real this time
if (in >> tempX>>tempY>>tempZ)
if (t>=MAX)
in>>tempX[t];
in>>tempY[t];
in>>tempZ[t];
break;
}
ofstream out(h);
if (!out){
cerr<<"Failed to open output file"<<h<<endl;
exit(1);
}
out<<"The unsorted list:"<<endl;
for (int s=0; s<t, ++s;){
out<<"\n\n"<<tempX[s]<<"\t\t"<<tempY[s]<<"\t\t07"<<tempZ[s]<<endl;
}
in.clear();
in.close();
out.close();
}
the error that is coming up is due to
for (int s=0; s<t, ++s;){
out<<"\n\n"<<tempX[s]<<"\t\t"<<tempY[s]<<"\t\t07"<<tempZ[s]<<endl;
}
and this
while(in){ // read the data for real this time
if (in >> tempX>>tempY>>tempZ)
if (t>=MAX)
in>>tempX[t];
in>>tempY[t];
in>>tempZ[t];
break;
}
and the error is error C2109: subscript requires array or pointer type.