C ++ inventory system

1

I'm doing a program in c ++ that consists of an inventory system, I'm asked for the following menu:

  • Enter an article
  • Edit an article
  • Delete an article
  • List the inventory
  • List inventory of depleted products
  • Exit the program
  • For now in this case I'm just working on the option to enter an article and I am asked for the following requirements for the creation of an article:

    • a) Code
    • b) Description
    • c) Cost

    For which I have created the following code:

    #include <iostream>
    #include <stdlib.h>
    #include <string>
    using namespace std;
    
    int main()
    {
    
    int NE,i=0,R;
    string vector[50];
    
    do{
    
    cout<<"1.Introducir articulo\n2.Modificar un articulo\n3.Eliminar un articulo\n4.Listar el inventario\n5.Listar inventario de productos agotados\n6.Salir del programa\n";
    cin>>NE;
    system("cls");
    
    
    switch(NE){
        case 1:
            i++;
    
            cout<<"Ingrese nombre del articulo\n";
            cin>>vector[i];
    
    
            cout<<"El nombre de articulo es:"<<vector[i]<<"\n";
                break;
    
    
    
        default:
        cout<<"Opcion aun no disponible\n"; 
    
    
    
        }
        system("pause");
        system("cls");
        cout<<"Desea regresar al menu principal?\n";
        cout<<"Y. N.\n";
        cin>>R; 
    }while(R=='Y');
    
    
    system("pause");
    return 0;
    }
    

    As you can see I have declared a vector of 50 spaces that for the moment will only store the name of the article to be introduced, besides having a cyclical structure "do while" and an iterator "i" that will serve to save the names of different articles in different memory spaces each time the process repeats itself, but my problem is that when I finish entering and saving the name of an article and want to repeat the process to enter another article my "do while" does not work and the program closes, thus losing the vector data, any help or advice is welcome.

        
    asked by Sasori1264 08.05.2018 в 03:02
    source

    1 answer

    2

    with cin >> R you're asking for an integer, when you should ask for a character (for Y / N).

    Change the type of your variable, and everything should work:

    char R;
    
        
    answered by 08.05.2018 / 07:31
    source