I am at the beginning of creating a linked list but program is not working properly because address "list" in main is not getting the value I am assigning it inside of function. What am I doing wrong please help.
#include <iostream>
#include <string>
using namespace std;
struct node
{
string ssno;
string lastName;
string firstName;
int age;
float height;
node *next;
};
void main()
{
void createlist(node *);
node *list = NULL;
createlist(list);
cout << list->ssno;
}
void createlist(node *list)
{
node *temp;
temp=new node;
temp->ssno="123-45-6789";
temp->next=list;
list = temp;
}
#include <iostream>
#include <string>
using namespace std;
struct node
{
string ssno;
string lastName;
string firstName;
int age;
float height;
node *next;
};
void main()
{
void createlist(node *);
node *list = NULL;
createlist(list);
cout << list->ssno;
}
void createlist(node *list)
{
node *temp;
temp=new node;
temp->ssno="123-45-6789";
temp->next=list;
list = temp;
}