ERROR: Program received signal SIGSEGV, Segmentation fault.
Hi,
I'm writting a C program for my university assignment in data structures. The program uses the radix(bucket) sort method to sort strings. One of the requirements is to use linked lists in sorting. I got no compile error,but when I runed the program I got an error that says: Program received signal SIGSEGV, Segmentation fault.
It also refers to the location of the problem which is in the function isLast , here's the code :
Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAXSIZ 15
#define number_of_alpha 53
typedef struct Node{
char word[MAXSIZ]; // to hold the string
struct node *next; // to point to the next node
}Node;
typedef struct Node *PtrToNode; // Pointer to a node (typedef)
typedef PtrToNode Position; // Pointer to a node
typedef PtrToNode List; // Pointer that points to the header node
void Sort();
void add( char*,List);
void moveNode(List,List,Position);
void moveBack (Position,List);
Position findPrevious(Position,List);
int isLast(Position);
void print(List);
int empty(List);
and the implementation of isLast :
int isLast(Position p) //parameter p points to a node
{
return p->next == NULL;
}
I actually called this funtion in the add function in order to determine the last node.
But I can't figure out the reason of this error , any help would be appreciated.
Thanks in advance.