开发者

Segfault: don't know where to start [closed]

Closed. This question needs debugging details. It is not currently accepting answers.

Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.

Closed 3 years ago.

Improve this question

I'm trying to compile开发者_如何学C this program under Windows (it's a program which turns bootable code in floppies. I got the source from here: http://www.acm.uiuc.edu/sigops/roll_your_own/1.bootstrap.html).

First I got the problem that it didn't read the INI file. That is solved now. Now I get a segfault on the following rule:

while(data < end) 

I added output to the app, so it should be clear where the executing stops: no "."'s are printed out. I'm on Win64, with the Cygwin toolchain.

Thanks!

Yvan


A mistake is:

size = (int *)lSize;

Better:

*size = lSize;

and the function as:

void *loadfile(char *file, long *size)
...

and in calling context eg:

long size=0;
char *buffer = loadfile("blah.txt",&size);
if( buffer )
{
  printf("\nstrlen = %lu, fsize = &ld", strlen(buffer), size );
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜