saving data into a file

This is a discussion on saving data into a file within the C Programming forums, part of the General Programming Boards category; Hi every1! Im implementing a web cache, and i've a buffer which has the data of a specific file, when ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    2

    saving data into a file

    Hi every1!
    Im implementing a web cache, and i've a buffer which has the data of a specific file, when i want to write it into a file. It works for text/plain data, but when i use images it doesnt work. For example, im doing something like this:

    FILE* fp;
    fp = fopen("mypicture.jpg","wb");

    is there anykind of processing i must do everytime i use image files?

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,799
    Quote Originally Posted by afrm
    It works for text/plain data, but when i use images it doesnt work.
    Please define "it doesn't work".
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Awesomefaceradcore bivhitscar's Avatar
    Join Date
    Apr 2006
    Location
    Melbourne, Australia
    Posts
    210
    Have a read of this - http://www.cprogramming.com/tutorial/cfileio.html, it might alleviate some issues.
    it's ironic considerate rarity patron of love higher knowledge engulfs me...

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    2
    hk_mp5kpdw, "doesnt work" means i cant open the jpg file where i store the data.

  5. #5
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    is the file already open by some other process? If it is, then your program cannot open it for output. Otherwise that open statements should work ok for any type of file.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  2. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 09:46 AM
  3. spell check in C using a dictionary file
    By goron350 in forum C Programming
    Replies: 10
    Last Post: 11-25-2004, 05:44 PM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM

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