Problem readinf from file...

This is a discussion on Problem readinf from file... within the C++ Programming forums, part of the General Programming Boards category; I have this as a private on my class: Code: unsigned int cantFrames; And this is in its constructor: Code: ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    55

    Problem readinf from file...

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

    Code:
    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:

    Code:
    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...
    fclose(ippFile);

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

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    55
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21