Segmentation fault on the server, but not 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;
}
EDIT: It's not my program.
I wish I knew enough C in order to fix it, but I'm on a deadline. This program is meant to find the first occurrence of a 7 digit number in the PI sequence, index.dat contains an huge array number = position.
http://jclement.ca/fun/pi/search.cgi