Segmentation Fault (C) occur on the server, but works on local machine
- by menachem-almog
As stated in the title, the program is working on my local machine (ubuntu 9.10) but not on the server (linux). It's a grid hosting hosting package of godaddy.
Please help..
Here is the code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
long offset;
FILE *io;
unsigned char found;
unsigned long loc;
if (argc != 2)
{
printf("syntax: find 0000000\n");
return 255;
}
offset = atol(argv[1]) * (sizeof(unsigned char)+sizeof(unsigned long));
io = fopen("index.dat","rb");
fseek(io,offset,SEEK_SET);
fread(&found,sizeof(unsigned char),1,io);
fread(&loc,sizeof(unsigned long),1,io);
if (found == 1)
printf("%d\n",loc);
else
printf("-1\n");
fclose(io);
return 0;
}