I'm trying my best to learn linked lists but am having a difficult time understanding them exactly any way debugger returns SIGSEGV
Debug Info:
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.7.50.20071127
Child process PID: 1572
Program received signal SIGSEGV, Segmentation fault.
At C:/Documents and Settings/anarionist/Desktop/rlgc/testing/main.cpp:21
NOTE: i am using gcc with codeblocks
code:
#include <iostream>
using namespace std;
typedef struct node *p;
typedef struct data * d;
struct node{
p next;
d dat;
};
struct data{
int id;
};
int main(){
int x;
p root;
d base;
base->id=0;
if(x!=20){
root->next=new node; // i believe this is my problem but im not sure how to fix it. this is also my first time using the -> which i understand to be "points to"?
base->id=base->id++;
cout<<base->id;
x++;
}
}