Greetings.
It's my first time in forums, I'm learning C ++, and I have had a problem; I have to do a program that at first allows me to add student data to an arrangement.
The problem is that it does not matter how many students you indicate to the program that I want to enter; because it allows me to enter only two students and then a window appears that says that the program stopped working.
I have tried to do it in two ways, with switch, and with switch and with functions, and in both cases the same thing happens to me; here I copy the code of the switch intent and functions, from now on thanks to whoever takes the time to help me.
#include<iostream>
#include<stdlib.h>
using namespace std;
void agregar();
int main(){
//muestra el menu, y permite ejecutar la opcion 8.(salir del programa)
int opcion;
cout << "Que desea hacer?" << endl;
cout << endl;
cout << "1.Aregar alumno" << endl;
cout << "2.Agregar notas de alumno" << endl;
cout << "3.modificar notas de alumno" << endl;
cout << "4.Eliminar alumno" << endl;
cout << "5.Mostrar lista de aprobados" << endl;
cout << "6.Mostrar list de reprobados" << endl;
cout << "7.Mostrar toda la lista de alumnos" << endl;
cout << "8.Salir del programa" << endl;
cout << endl;
cin >> opcion;
switch(opcion){
case 1:{
agregar();
break;
}
}
system ("pause");
return 0;
}
void agregar(){
// variables utilizadas en void agregar()
int m = 0, n = 0, i, r = 0;
string codigo[m], nombre[m], grado[m];
cout << "Cuantos alumnos desea agregar? ";
cin >> m;
n = n + m;
cout << "ingrese los datos: " << endl;
for(i = 0; i < m; i++){
cout << "nombre del alumno " << i + 1 << ": ";
cin >> nombre[i];
}
cout << "Desea ingresar mas alumnos? ";
cout << "1.SI";
cout << "2.No";
cin >> r;
if(r = 1){
m = 0;
void agregar();
}else{
m = 0;
int main();
}
system ("pause");
}