online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include<iostream> #include<string.h> using namespace std; // Estrucutura para maestro. struct maestro{ char nombre[20], apellido[20], pais[20], especialidad[20]; int edad; }; // Estructura para fecha. struct fecha{ int dia, mes, anio; }; // Estructura cursos. struct cursos{ char nombre[20], especialidad[20]; maestro maesCursos; fecha fech; }; int main(){ char especialidad[3][20] = {"programacion","base de datos","servidores"}; int opcion = 0; maestro maestroRegistros[2]; cursos cursosRegistros[2]; //Registro de maestros. //Mestro1 strncpy(maestroRegistros[0].nombre, "Angel", sizeof(maestroRegistros[0].nombre)); strncpy(maestroRegistros[0].apellido, "Sanchez", sizeof(maestroRegistros[0].apellido)); maestroRegistros[0].edad = 27; strncpy(maestroRegistros[0].pais, "Mexico", sizeof(maestroRegistros[0].pais)); strncpy(maestroRegistros[0].especialidad, especialidad[0], sizeof(maestroRegistros[0].especialidad)); //Mestro2 strncpy(maestroRegistros[1].nombre, "Victor", sizeof(maestroRegistros[1].nombre)); strncpy(maestroRegistros[1].apellido, "Urbina", sizeof(maestroRegistros[1].apellido)); maestroRegistros[1].edad = 27; strncpy(maestroRegistros[1].pais, "Mexico", sizeof(maestroRegistros[1].pais)); strncpy(maestroRegistros[1].especialidad, especialidad[1], sizeof(maestroRegistros[0].especialidad)); //Registro de cursos. //Curso 1 strncpy(cursosRegistros[0].nombre, "Curso de C++", sizeof(cursosRegistros[0].nombre)); strncpy(cursosRegistros[0].maesCursos.nombre, maestroRegistros[0].nombre, sizeof(cursosRegistros[0].maesCursos.nombre)); strncpy(cursosRegistros[0].especialidad,especialidad[0] , sizeof(cursosRegistros[0].especialidad,especialidad[0])); cursosRegistros[0].fech.dia = 13; cursosRegistros[0].fech.mes = 4; cursosRegistros[0].fech.anio = 2020; //Curso 2 strncpy(cursosRegistros[1].nombre, "Curso de SQL", sizeof(cursosRegistros[1].nombre)); strncpy(cursosRegistros[1].maesCursos.nombre, maestroRegistros[1].nombre, sizeof(cursosRegistros[1].maesCursos.nombre)); strncpy(cursosRegistros[1].especialidad,especialidad[1] , sizeof(cursosRegistros[1].especialidad,especialidad[1])); cursosRegistros[1].fech.dia = 15; cursosRegistros[1].fech.mes = 5; cursosRegistros[1].fech.anio = 2022; cout<<"------- Cursos Azul School -------"<<endl; cout<<"Buscar cursos:"<<endl<<endl<<"1 Por nombre de maestro"<<endl<<"2 Por especialidad"<<endl<<"3 Mayores a un anio"<<endl<<"4 Menores a un anio"<<endl<<endl; cin>>opcion; char nombre[20], especilidades[20]; int anio; switch(opcion){ case 1: cout<<endl<<"Ingrese el nombre del maestro: "; cin>>nombre; for(int i = 0; i<=1; i++){ int res = strcmp(cursosRegistros[i].maesCursos.nombre,nombre); if(res == 0){ cout<<endl<<"------- Registro encontrado -------"<<endl; cout<<"Maestro: "<<cursosRegistros[i].maesCursos.nombre<<" "<<cursosRegistros[i].maesCursos.apellido<<endl; cout<<"Curso: "<<cursosRegistros[i].nombre<<endl; cout<<"Especilidad del curso: "<<cursosRegistros[i].especialidad<<endl; cout<<"Fecha del curso: "<<cursosRegistros[i].fech.dia<<"-"<<cursosRegistros[1].fech.mes<<"-"<<cursosRegistros[i].fech.anio; } } break; case 2: break; case 3: break; case 4: break; default: cout<<"Opcion no valida"; break; } return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue