Hi..

i would like to know why this code is working :

Code:
#include <stdio.h>#include <stdlib.h>




typedef struct
{       
       
       int mem;
       struct node *next;
       
}NODE;






int main(int argc, char *argv[])
{
    NODE n;
    
    NODE *pt;
    NODE *spt;
    
    pt = &n;
    
    
    int i;
    //create more nodes
    for(i = 0 ; i < 10 ; i++){
          
          pt -> mem = i + 1;
          pt -> next = malloc(sizeof(NODE));
          pt = pt -> next;
    }
    printf("Created\n");
   
   //display 
    pt = &n; 
    for(i = 0 ; i < 10 ; i++){
          
          printf("%d\n", pt -> mem );
          pt = pt -> next;
    }
    
    
    //free memory      
    pt = &n; 
    pt = pt -> next;
    for(i = 0 ; i < 10 ; i++){
          
          spt = pt -> next;
          free(pt);
          pt = spt -> next;
          
          printf("freed %d\n" , i);
    }
          
    
  
  getchar();
  return 0;
}
shouldn't the compiler complain about node (in the struct definition) not being declared?

I am using dev-c++.. and when i tried to compile the code on codepad i got segmentation fault.