I throw compilation error in the following code.
#include <iostream>
#include <windows.h>
#include <string>
#include <sstream>
#include <stdio.h>
#include <conio.h>
#define TOTAL 1000
using namespace std;
struct Alumno
{
string nombre[50];
char apellido[50];
int dni;
int legajo;
};
int Ingresar_Alumno (int &e)
{
FILE *Estudiante;
Alumno vectoralumno[TOTAL];
if (Estudiante=fopen("Estudiante.dat", "ab+"))
{
std::string name;
cout << "ingrese el nombre del alumno: ";
getline(cin, vectoralumno[e].nombre);
cout << "ingrese el apellido del alumno: ";
getline(cin, vectoralumno[e].apellido);
cout << "ingrese legajo del alumno: ";
getline(cin, vectoralumno[e].legajo);
cout << "ingrese el DNI del alumno: ";
getline(cin, vectoralumno[e].dni);
fwrite(&vectoralumno[e],sizeof(Alumno),1,Estudiante);
}
fclose(Estudiante);
e++;
}
Most likely, he's doing something wrong in the syntax. Previously I used cin >> vectoralumno[e].nombre;
but when I entered the name and the person had two names (eg Andres Osvaldo) I skipped the option to enter surname