Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Cadena de una estructura

0 votes
asked Jun 15, 2022 by Agustin (120 points)
No me deja ingresar valores en la cadena "vecdescripcion", la saltea, no se que hacer, el codigo es:

#include <iostream>
using namespace std;
struct entrada {
    char vecdescripcion[30];
    int precio;
    int cantidadvendidos;
void CargaProds(entrada salida[]) {
    int n,i;
    i = 0;
    cin >> n;
    for (int i = 0; i < 5; i++) {
        cout << "Ingrese descpricpion de producto\n";
        cout << salida[i].vecdescripcion;
        cout << "Ingrese precio unitario" << endl;
        cin >> salida[i].precio;
        cout << "Ingrese la cantida de ventas de ese producto" << endl;
        cin >> salida[i].cantidadvendidos;
int main()
    cout << "Ing. cantidad de productos que maneja el comercio " << endl;
    entrada salida[5];

1 Answer

0 votes
answered Jun 16, 2022 by Peter Minarik (72,620 points)

You have the same problem as this. Check the Mixed Input Methods section of my answer there.

TL;DR; Do not mix getline() with other methods that read from the stdin.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.