Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. fopen,ftell & AMD64..... they fails??!?

fopen,ftell & AMD64..... they fails??!?

Scheduled Pinned Locked Moved C / C++ / MFC
jsonarchitecturehelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paolo Ponzano
    wrote on last edited by
    #1

    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 at wav->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

    B 1 Reply Last reply
    0
    • P Paolo Ponzano

      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 at wav->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

      B Offline
      B Offline
      bikram singh
      wrote on last edited by
      #2

      I 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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups