ungültige Konvertierung von 'int' nach 'char *'

Es wird angenommen, dass ich ein Programm schreibe, das aus einer Textdatei liest und das, was sich in der Textdatei befindet, unter Verwendung von Strukturen speichert und die Informationen in der Textdatei umgruppiert und druckt. Aber ich habe Probleme mit gestoßengetline. Ich habe versucht zu schreibengetline so was

getline(infile, info.name)

aber es geht nicht. Ich habe auch enthalten<string> und<cstring> aber ich stoße trotzdem auf fehler wie

Fehler C2664: 'std :: basic_istream <_Elem, _Traits> & std :: basic_istream <_Elem, _Traits> :: getline (_Elem *, std :: streamsize)': Parameter 1 kann nicht von 'int' in 'char *' konvertiert werden

und

Fehler C2664: 'std :: basic_istream <_Elem, _Traits> & std :: basic_istream <_Elem, _Traits> :: getline (_Elem *, std :: streamsize, _Elem)': Parameter 1 kann nicht von 'char [10] [80' konvertiert werden ] 'zu' char * '

Die Textdatei, die ich ausdrucken soll, ist der folgende Text

Isabella Chan
Republik Singapur
Waage 23 - 10 - 1993
7
Ich möchte gut in c ++ sein
Ich wünsche mir, dass christina grimmie die stimme gewinnt
Ich wünsche mir, dass ......

Sorry für die noob Frage und vielen Dank im Voraus!

   #include <iomanip>
   #include <iostream>
   #include <cstdlib>
   #include <ctime>
   #include <cctype>
   #include <fstream>
   #include <string>

   using namespace std;

   const int MAX = 80;
   const int MAXNO = 10;
   enum Zodiac 
   {
            Aquarius, Pisces, Aries, Taurus,
            Gemini, Cancer, Leo, Virgo,
            Libra, Scorpio, Sagittarius, Capricorn
   };
   struct Date
   {
       Zodiac sign;
       int day;
       int month;
       int year;
   };
   struct Student
   {
           char name [MAX];
       char nationality [MAX];
       Date birthDate;
       int no; // no of other messages
       char wishMessage [MAXNO][MAX];
       // Feel free to add in more features
   };

   void myInfo (fstream&, char [], Student&);
   // The above function reads information from the text file
   // and store the information in a structure reference parameter

   void printOut(Student);

   int main()
   {
       fstream infile;
       char fName[MAX];
       Student info;
       cout << "Enter your info file name: "
       cin  >> fName; 
       cout << endl;

       myInfo(infile, fName, info);
       printOut(info);

   }

   void myInfo (fstream& infile, char fName[], Student& info)
   {
          infile.open(fName, ios::in);

      if(!infile)
      {
           cout << "Error file not found!" << endl;
           exit(0);
      }
       infile.getline(info.name, MAX);
       infile.getline(info.nationality,MAX);
       infile  << info.birthDate.sign
           << info.birthDate.day
           << info.birthDate.month
           << info.birthDate.year;
       infile.getline(info.no, MAX);
       infile.getline(info.wishMessage, MAXNO, MAX);

       infile.close();
       cout << "Successfully readed!" << endl;

   }

   void printOut(Student info)
   {
       cout << "My name is " << info.name << endl;
       cout << "My nationality is " << info.nationality << endl;
       cout << "My date of birth is " << info.birthDate.day 
            << " " << info.birthDate.month << " " 
        << info.birthDate.year << endl;
       cout << "I am " << info.birthDate.sign << endl;
       cout << "\n I have " << info.no << " wishes:" << endl;

   }

Antworten auf die Frage(1)

Ihre Antwort auf die Frage