online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <iomanip> #include <cstring> #include <limits> using namespace std; const int CAPACIDAD = 5; typedef struct { char nombre[CAPACIDAD]; int precio; } Producto; void intercambiar(Producto* ptr1, Producto* ptr2); void ingresar(Producto* ptr, int cap); void mostrar(Producto* ptr, int cap); int main() { Producto* ptr = nullptr; int n = 0; cout << "ingrese la cantidad de items a ingresar\t:\t"; cin >> n; cin.get(); ptr = new Producto[n]; ingresar(ptr, n); mostrar(ptr, n); intercambiar(ptr, ptr + 1); mostrar(ptr, n); delete[] ptr; ptr = nullptr; } void intercambiar(Producto* ptr1, Producto* ptr2) { char nombre_aux[CAPACIDAD] = ""; int precio_aux = 0; strcpy(nombre_aux, ptr1->nombre); strcpy(ptr1->nombre, ptr2->nombre); strcpy(ptr2->nombre, nombre_aux); precio_aux = ptr1->precio; ptr1->precio = ptr2->precio; ptr2->precio = precio_aux; } void ingresar(Producto* ptr, int cap) { for (int j = 0; j < cap; ++j) { ptr[j].precio = 3 + rand()%4; cout << "nombre del producto\t:\t"; cin.getline(ptr[j].nombre, CAPACIDAD); if (cin.fail()) { cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); } } } strcmp(cad1,cad2) void mostrar(Producto* ptr, int cap) { cout << "\t\t\t" << setw(CAPACIDAD) << "Nombre" << "\tPrecio\n"; for (int j = 0; j < cap; ++j) { cout << "Item " << j << "\t:\t" << setw(CAPACIDAD) << ptr[j].nombre << "\t\t" << ptr[j].precio << endl; } }

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