file saving with frog!!!

This is a discussion on file saving with frog!!! within the C++ Programming forums, part of the General Programming Boards category; well the problem is simple, i don't know how haha (i haven't got enough sleep bare with me) alright i ...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    11

    file saving with frog!!!

    well the problem is simple, i don't know how haha
    (i haven't got enough sleep bare with me)

    alright i understand how to open/save/edit text based files
    using C++, I have covered most basic tutorials on C++
    directx, api, mfc, anything i can get my hands on
    including networking(but that still needs work)

    the one thing that i haven't come across is how to access
    data from anouther file within the program?

    i mean data not text based accual data like stored
    variables or something from anouther file??

    if that makes sense sorry if it doesn't

  2. #2
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    ................
    The world is waiting. I must leave you now.

  3. #3
    SmoothCriminal
    Guest
    how do i save a file at all?

  4. #4
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    be a little more specific. what are you trying to do? save your programs state in a file and then load that up and resume you prog. with the data stored in the file? thats a pretty simple task if you alredy know how to read/write to files and if the file is laid in an orderly fassion (i.e. you wrote the file how you wanted it or it follows a strict guidline set down in its formats if so go to http://www.wotsit.org/ and look around at the different formats.
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  5. #5
    Seven years? civix's Avatar
    Join Date
    Jul 2002
    Posts
    605
    OK, I'm only thinking that this is your problem: Saving file to specified location:
    Code:
    //Be Sure to include fstream.h!
    
    ofstream save;
    
    save.open("C:\savedfile.txt");
    save<<"Hello";
    save.close();
    Opening a file from a specified location:

    Code:
    //Be Sure to include fstream.h!
    
    ifstream open;
    
    open.open("C:\savedfile.txt");
    if(open.fail())
    {
    cout<<"file opening has failed.";
    }
    open.close();
    I'm only assuming that that was your problem...I hope it helped.

  6. #6
    Registered User
    Join Date
    Aug 2002
    Posts
    11

    hmm....

    ok
    i am wondering how i would save cetain information
    into a file *.whatever. things such as variables.
    then i could load these variables back into memory and
    manipulate them.
    i think it would be in binary format like a binary tree or
    something like that. i hope that is a little more clear

  7. #7
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    i am wondering how i would save cetain information into a file *.whatever. things such as variables then i could load these variables back into memory and manipulate them.
    Those two sentences make me think that you dont even know how to read from a file. If you do then this should be a no brainer, you wrote the file so you know how its laid out, just write some code to read in the data and assign it to your variables.
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  8. #8
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Originally posted by civix

    save.open("C:\savedfile.txt");
    open.open("C:\savedfile.txt");
    Important : You have to specify double backslashes in order to generate one backslash.
    The string should be: "C:\\savedfile.txt"
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 07:54 AM
  3. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM

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