fopen,ftell & AMD64..... they fails??!?
-
hello, I've just bought an AMD64 processor, and I'm coding a new console apps using CRT libraries, I need to get file size lenght but I don't know if I'm really low with skill coding (maybe) or if it's some problem with the architecture I've and the following code
long FileSize(FILE *fd) { long siz=0; if( fd == NULL) { return -1; } fseek (fd, 0, SEEK_END); siz=ftell(fd); rewind(fd); fclose(fd); return siz; };
this piece of code is called atwav->fd =fopen(argv[1],"rb"); if(wav->fd == NULL) { printf("Unable to obtain an handle to %s\n",argv[1]); exit(-1); } strncpy((wav)->filename,argv[1],strlen(argv[1])); //I get file size wav->filelenght =FileSize(wav->fd);
in the main. I always obtain 0... I just want to know if someone else is coding with AMD64 and has success with those API, thanks -
hello, I've just bought an AMD64 processor, and I'm coding a new console apps using CRT libraries, I need to get file size lenght but I don't know if I'm really low with skill coding (maybe) or if it's some problem with the architecture I've and the following code
long FileSize(FILE *fd) { long siz=0; if( fd == NULL) { return -1; } fseek (fd, 0, SEEK_END); siz=ftell(fd); rewind(fd); fclose(fd); return siz; };
this piece of code is called atwav->fd =fopen(argv[1],"rb"); if(wav->fd == NULL) { printf("Unable to obtain an handle to %s\n",argv[1]); exit(-1); } strncpy((wav)->filename,argv[1],strlen(argv[1])); //I get file size wav->filelenght =FileSize(wav->fd);
in the main. I always obtain 0... I just want to know if someone else is coding with AMD64 and has success with those API, thanksI doubt your problem is the CPU. Anyway, try removing or correcting this line. It is incorrect:
strncpy((wav)->filename,argv[1],strlen(argv[1]));
Should be:strncpy(wav->filename,argv[1],sizeof(wav->filename)-1);
Bikram Singh