LinkedList Node

I need to create a simple linked list but can't even get the head pointer to initialize. I am pulling my hair out trying to figure out what I'm doing wrong. It may have something to do with the struct portion of my code. Any help would be much appreciated!


using namespace std;

struct Node// Should I have typedef struct Node?
int data;
Node *next;
//Main function
int main()
new Node *pHead = NULL;//<-error in this line (";" expected before pHead)
pHead->data=7;//<-error in this line('pHead' undeclared, first use...)
cout << pHead->data;
delete pHead;


new Node *pHead = NULL;


Node *pHead = new Node();
Awesome thank you so much! I feel silly now but appreciate it very much.
Topic archived. No new replies allowed.