online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <cstring> using namespace std; // estructura Estudiante con tres campos struct Estudiante { // char* nombre; const char* nombre; int id; int edad; }; // especificando reglas de la comparacion // para ordenar los estudiantes basados en nombres int comparator(const void* p, const void* q) { return strcmp(((struct Estudiante*)p)->nombre, ((struct Estudiante*)q)->nombre); } // funcion controladora int main() { int i=0, n=5; struct Estudiante arr[n]; // Obteniendo los datos de los estudiantes arr[0].id = 1; arr[0].nombre = "Ramos"; arr[0].edad = 22; arr[1].id = 2; arr[1].nombre = "Ciocca"; arr[1].edad = 20; arr[2].id = 3; arr[2].nombre = "Bahamonde"; arr[2].edad = 18; arr[3].id = 4; arr[3].nombre = "Huilca"; arr[3].edad = 19; arr[4].id = 5; arr[4].nombre = "Meretz"; arr[4].edad = 20; // Imprime la estructura sin clasificar cout<<"Registros de estudiantes sin clasificar:\n"; for(i=0; i<n; i++) { cout<<"Id = "<<arr[i].id <<" | Nombre = "<<arr[i].nombre <<" | Edad = "<<arr[i].edad<<"\n"; } // Ordenando la estructura // basedo en el comparador especifico qsort(arr, n, sizeof(struct Estudiante), comparator); // Imprime la estructura ordenada cout<<"\nRegistros del estudiante ORDENADOS POR NOMBRE: \n"; for (i=0; i<n; i++) { cout<<"Id = "<<arr[i].id <<" | Nombre = "<<arr[i].nombre <<" | Edad = "<<arr[i].edad<<"\n"; } 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