How do I add second element ? right now it works and I get output of 13, but lets say I want list of 2 elements, how do I do that ? here's my code :
#include <iostream>
using namespace std;
struct Vagon{
int num;
Vagon *p_next_num;
};
int main()
{
Vagon *head_of_list; // korijen liste, bez ovog ne bi mogli nac listu u memoriji
Vagon *konduktor; // ova var ce upucivati na svaki vagon kako budemo isli kroz listu
Vagon *next_element;
head_of_list = new Vagon;
head_of_list->num=13;
head_of_list->p_next_num = 0;
konduktor = head_of_list;
if(konduktor->p_next_num != 0){
while(konduktor->p_next_num !=0)
cout << konduktor->num;
konduktor = konduktor->p_next_num;
}
cout << konduktor->num;
}