Thank you all for posting great help on my last question. This is one hell of a site for knowledge.
I have another question. I am starting on pointers and linked lists. I understand the concept of how they are made, the head and tail and how to add one (mostly), this may sound silly but how to you make the contents? I see how you make the first one, but how do u add more info. Heres an example of what I know.
Creating one
Code:
#include<iostream>
using namespace std;
typedef struct node // linked list structure
{
int data; // will store information
node *next; // the reference to the next node
};
node *temp= new node;
node *head = NULL; //empty linked list
node *tail = new node;
int main()
{
cout << "Please enter the number data ";
cin >> temp->data;
cout << temp->data;
temp->data=head;
temp->next=head;
head=temp;
cout << head;
system("pause");
return 0;
}
{
some of this is wrong but how do u make more info. Like say i wanted the first node to be data=1 then the second node to be data =2 and 3 for the 3rd and so on until the last being Null. any suggestions??