Thread: Problem readinf from file...

  1. #1
    Registered User
    Join Date
    Apr 2007

    Problem readinf from file...

    I have this as a private on my class:
    unsigned int cantFrames;
    And this is in its constructor:

    IPPHeader::IPPHeader(FILE* ippFile){
    	fread(&cantFrames, sizeof(unsigned int), 1, ippFile);

    My program hangs on that fread. I get that Windows "Send/Don't Send" error... I checked if ippFile was NULL, but it's not... What may be wrong?

    Oh, BTW, this is how I stored that data on the file, on a completely different application:

    FILE* ippFile
    ippFile = fopen(fileName,"wb");
    unsigned int cantFrames = 9;
    fwrite(&cantFrames,sizeof(unsigned int),1,ippFile);
    //I wrote more things, but it doesn't matter as I can't even read the first one...

  2. #2
    Registered User Noir's Avatar
    Join Date
    Mar 2007
    You should be casting cantFrames:
    fread((char*)&cantFrames, sizeof(unsigned int), 1, ippFile);

  3. #3
    Registered User
    Join Date
    Apr 2007
    No, it wasn't that... It was a silly mistake of my part... I was opening the file after that constructor was called...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  2. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  3. File I/O problem
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 12
    Last Post: 09-03-2005, 12:14 PM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  5. Rename file problem
    By Emporio in forum C Programming
    Replies: 2
    Last Post: 06-05-2002, 09:36 AM