Hello and Happy New Year,
I have a problem with a program which running well in DOS, but not at all under
Linux. I used (for the first time) gdb, and this happened:
-----------------------------------------------
(gdb) run
Starting program: /root/c/a.out
Program received signal SIGSEGV, Segmentation fault.
0x40053cee in memcpy (dstpp=0x1, srcpp=0x400b6000, len=120)
at ../sysdeps/generic/memcpy.c:40
../sysdeps/generic/memcpy.c:40: No such file or directory.
(gdb) next
Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
-----------------------------------------------
The program is simple, so what is the problem? I don't have the right memcpy.c
file, or it's an error on 40 line of memcpy.c?
----------------------------------------------------------------------------
// My program
#include <stdio.h>
#include <string.h>
const dim=123;
FILE *f;
int i;
int main()
{
char *word, *buf;
char en[41], rom[81];
unsigned long t;
printf("WORD: ");
scanf("%s",word);
if ((f = fopen("//misc//dos//cpp//english//dict_er", "rb")) == NULL)
{
fprintf(stderr, "Cannot open input file.\n");
return 1;
}
// Here, if a comment the following three lines, the program works fine.
// I have tried fread instead of fgets, but the same result.
do
fgets(buf, dim+1, f);
while(strncmp(buf,word,strlen(word)));
if ((t=ftell(f)) <= dim*9)
fseek(f, 0, SEEK_SET);
else
fseek(f, -dim*9, SEEK_CUR);
do
{
fread(en, 41, 1, f);
printf("| %.25s| ",en);
fread(rom, 81, 1, f);
printf("%.50s|",rom);
fseek(f, 1L, SEEK_CUR);
}
while( (ftell(f) < t+dim*8) && strncmp(en,"zuc",3) );
// Here I want to put while(... && !feof(f));
// but the program running and running...
// and doesn't stop !?!
fclose(f);
return 0;
}
----------------------------------------------------------------------------
Thanks,
Cata.
--
=/^\_/^\_/^\_/^\_/^\_/^\_/^\_/^\_/^\_/^\_/^\_/^\=
\ Don't believe all you hear, /
/ spend all you have, \
\ or sleep all you want. /
/=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\
\ Catalin Bucur, /
/ Hardware engineer mailto:[EMAIL PROTECTED] \
=/^\_/^\_/^\_/^\_/^\_/^\_/^\_/^\_/^\_/^\_/^\_/^\=