I am learning some data structure stuff and I faced a problem that I did not even expected because normally I can solve this kind of error.
#include <iostream>
using namespace std;
struct Avion {
char* numePilot;
int nrPasageri;
};
struct nodDublu {
Avion info;
nodDublu* next;
nodDublu* prev;
};
struct ListaDubla {
nodDublu* first;
nodDublu* last;
};
Avion creareAvion(char* numePilot, int nrPasageri) {
Avion avion;
avion.numePilot = (char*)malloc(sizeof(char)*(strlen(numePilot) + 1));
strcpy_s(avion.numePilot, strlen(numePilot) + 1, numePilot);
avion.nrPasageri = nrPasageri;
return avion;
}
nodDublu* creareNod(Avion info, nodDublu* next, nodDublu* prev) {
nodDublu* nou = (nodDublu*)malloc(sizeof(nodDublu));
nou->info = creareAvion(info.numePilot, info.nrPasageri);
nou->next = next;
nou->prev = prev;
return nou;
}
ListaDubla inserareInceput(ListaDubla lista, Avion avion) {
nodDublu* nou = creareNod(avion, lista.first, NULL);
if (lista.first) {
lista.first->prev = nou;
lista.first = nou;
return lista;
}
else {
lista.first = nou;
lista.last = nou;
return lista;
}
}
void main() {
ListaDubla lista;
lista.first = NULL;
lista.last = NULL;
Avion avion = creareAvion("Ionescu", 34);
}
I put here the entire code, but obv the problem is somewhere at "creareAvion" which is the funct for creating Avion I guess. That "Ionescu" is not working because of that error.