How to know the segmentation faults in C? The code is below(seeing to the word limit its incomplete)
#include<stdio.h> #include<stdlib.h> struct node { int rno; struct node *next; }; void main() { int n,i,r; struct node *head; head=(struct node *)malloc(sizeof(struct node)); head=NULL; scanf("%d",&n); for(i=1;i<=n;++i) { scanf("%d",&r); if(head==NULL) { head->rno=r; head->next=NULL; } struct node *tmp; tmp=head; int f=0; while(tmp!=NULL) { if(tmp->rno==r) { f=1; break; } tmp=tmp->next; } if(f=0) { tmp->next=head; head=tmp; } if(f=1)