1
I have that code
int main() {
ListaVend lista;
criarLista(&lista);
for(int i = 0; i <= VEND_MAX; i++){
Vendedor vend;
vend.codVend = i;
vend.nome = "Vendedor "+to_string(i);
vend.salFinal = i;
inserLista(&lista, &vend, i);
}
showLista(lista);
That way it works normal. Now I wanted the Variable to be accessed outside the main too, as I can do this?
Ps.
ListaVend lista;
int main() {
criarLista(&lista);
for(int i = 0; i <= VEND_MAX; i++){
Vendedor vend;
vend.codVend = i;
vend.nome = "Vendedor "+to_string(i);
vend.salFinal = i;
inserLista(&lista, &vend, i);
}
showLista(lista);
This way you don’t save any information on the List.
If you are going to use out of main in another function, you can pass it by "reference" in the same way you used in the function creatList.
– Andrey França
So, just that I want to create a "menu" so I can manipulate this list. For example, access main calls menu, from menu access to insert option, after inserting back to menu... understood?
– hynzhw
Only with this passage can not know what is happening. But anyway do not do it. There is no reason to do. You have every reason not to.
– Maniero
From what I could see only with this excerpt "should" work; not knowing what this creatLista() works is difficult but, I think, which list is a list of "Seller" no? Why don’t you "use vector<seller> list" ?
– PerryWerneck
Sorry, here is my complete code: http://pastebin.com/eX9dZPqk It is that I am learning lists in college, ai queria fazer esse "menu" para poder deixar mais bonito e funcional
– hynzhw
Try passing the list as pointer in showlist: showList(&list);
– PerryWerneck
See if it helps: http://answall.com/q/99551/101 But reinforcement, ideally not. And I think it’s a shame that in a college you teach to mix C with C++.
– Maniero
Got it, Perry, I’m gonna try to implement this. And Bigown I’m gonna get a better handle on this.
– hynzhw