Segmentation Fault (C) occur on the server, but works on local machine

Posted by menachem-almog on Stack Overflow See other posts from Stack Overflow or by menachem-almog
Published on 2010-03-12T21:49:31Z Indexed on 2010/03/12 21:57 UTC
Read the original article Hit count: 488

Filed under:
|
|

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;
}

© Stack Overflow or respective owner

Related posts about c

    Related posts about segmentation-fault