Results 1 to 4 of 4

Thread: Fun Fun File I/O

  1. #1
    Zaei
    Guest

    Fun Fun File I/O

    Let DWORD fLen = 12, and BYTE pbuff = 0.
    f is a valid file, opened in binary mode.
    Code:
    fwrite(&pbuff, 1, 1, f);
    fwrite(&fLen, 4, 1, f);
    fwrite(&pbuff, 1, 1, f);
    Why does the output look like "00 0C 00", instead of "00 0C 00 00 00 00"?

    Z.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    seems to be some error, it works for me...
    Code:
    #include <stdio.h>
    
    int main(int argc, char* argv[])
    {
    	FILE* file;
    	unsigned long ulSome = 12;
    	unsigned char ucSome = 0;
    
    	file = fopen("testfile.dat", "wb");
    
    	fwrite(&ucSome, 1, 1, file);
    	fwrite(&ulSome, 4, 1, file);
    	fwrite(&ucSome, 1, 1, file);
    
    	fclose(file);
    
    	return 0;
    }
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Zaei
    Guest
    Yeah, it was a me-being-stupid kinda error =). I was writing out all four bytes, but over writing 3 of them. I fixed it last night. Thanks though!

    Z.

  4. #4
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    Edit first post and change the title to "Fun Fun File I/O - Resolved"
    thanks
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width