0

It's just a struct

#define _CRT_SECURE_NO_WARNINGS //def 

#include<iostream>
#include<conio.h>


using namespace std;

my struct

struct muncitor  
{
    int id;
    char *nume;
    float salariu;
    char init_t;
    bool fct_conducere;
    int nr_calificativ;
    int *calificativ;
};

reading struct content

void read(muncitor m) 
{

    cout << "Id: ";
    cin >> m.id;

    cout << "numele: ";
    char aux[20];
    cin >> aux;
    m.nume = new char[strlen(aux) + 1];
    strcpy(m.nume, aux);

    cout << "salariul: ";
    cin >> m.salariu;

    cout << "initiala: ";
    cin >> m.init_t;

    cout << "functie: ";
    cin >> m.fct_conducere;

    cout << "nr calificative: ";
    cin >> m.nr_calificativ;
    cout << m.nr_calificativ << " ";

    m.calificativ = new int[m.nr_calificativ]; here is the problem

    for (int i = 0; i < m.nr_calificativ; i++)
    {
        cout << "calificativul: ";
        cin >> m.calificativ[i];
    }

}

void main()
{

    muncitor m;

    m.id = 1;
    m.salariu = 1250;

    read(m); //call void
    _getch;
}

Can't figure it out. The debug stops at m.calificativ = new int[m.nr_calificativ]; What is wrong? Please help me. A test is coming soon. I can't find a solution, so I'm asking here.

Eli Sadoff
  • 7,173
  • 6
  • 33
  • 61
AndreiB
  • 3
  • 5

0 Answers0