Erreur de type incomplet Infile

Je construis un programme qui prend un fichier d’entrée dans ce format:

title author title author etc and outputs to screen title (author) title (author) etc 

Le problème que je reçois actuellement est une erreur:

“ifstream infile a un type incomplet et ne peut pas être défini”

Voici le programme:

 #include  #include  #include  using namespace std; ssortingng bookTitle [14]; ssortingng bookAuthor [14]; int loadData (ssortingng pathname); void showall (int counter); int main () { int counter; ssortingng pathname; cout<>pathname; loadData (pathname); showall (counter); } int loadData (ssortingng pathname) // Loads data from infile into arrays { ifstream infile; int counter = 0; infile.open(pathname); //Opens file from user input in main if( infile.fail() ) { cout <> bookTitle [14]; //takes input and puts into parallel arrays infile >> bookAuthor [14]; counter++; } infile.close; } void showall (int counter) // shows input in title(author) format { cout<<bookTitle<<"("<<bookAuthor<<")"; } 

Les stream de fichiers sont définis dans l’en-tête et vous ne l’ pas.

Vous devriez append:

 #include  

Voici mon code avec l’erreur précédente corrigé Maintenant, je reçois un problème de blocage du programme après avoir entré le nom du fichier texte.

 #include  #include  #include  using namespace std; ssortingng bookTitle [14]; ssortingng bookAuthor [14]; int loadData (ssortingng pathname); void showall (int counter); int main () { int counter; ssortingng pathname; cout<<"Input the name of the file to be accessed: "; cin>>pathname; loadData (pathname); showall (counter); } int loadData (ssortingng pathname) // Loads data from infile into arrays { fstream infile; int counter = 0; infile.open(pathname.c_str()); //Opens file from user input in main if( infile.fail() ) { cout << "File failed to open"; return 0; } while (!infile.eof()) { infile >> bookTitle [14]; //takes input and puts into parallel arrays infile >> bookAuthor [14]; counter++; } infile.close(); } void showall (int counter) // shows input in title(author) format { cout<