I have written the following code (names file is fine and that is not the issue. It is the old chesnut of converting char, char*, string arrays.
Code:#include <iostream> using namespace std; int main() { FILE *txtfile; char line[1024]; char studentlist[6]; int pos=0; if((txtfile=fopen("Names.DAT","r"))==NULL) exit(-1); cout << "The names in the text file are:" << endl; cout << endl; while(fgets(line,1024,txtfile)!=NULL) //cout << line; studentlist[0]=line; cout << studentlist[0]; fclose(txtfile); cin.get(); }



LinkBack URL
About LinkBacks



