Say I have
#include<iostream.h>
int tempNum;
struct node {
int data;
struct node *next;
};
struct node *newNode = NULL;
int main(void) {
tempNum = 5;
newNode->data = tempNum; //gives seg fault
}
*edit - I'm trying to add tempNum to the very first node.
I haven't worked with linked lists in a while and it's really giving me a headache. What's wrong?