Results 1 to 3 of 3

Thread: Very Simple, Need help quickly please

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    149
    Just wondering how you save a variable to a text file,

    like say I had a variable called EnteredInformation, and it held all the information that a user entered into a form, how would I then put that into a text file??

    Thanks


    -|- Hurgh -|-
    Email: [email protected]
    Website: http://www.hurgh.org/

    Unix, Linux, FreeBSD, OpenBSD, Solaris, Windows

    C, C++, PHP, VB6, ASP, VBScript, JavaScript

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    149
    Sorry and one other thing,

    How would I then later get the information that I put into that text file and put it back into the variable??


    Thanks Heaps

    -|- Hurgh -|-
    Email: [email protected]
    Website: http://www.hurgh.org/

    Unix, Linux, FreeBSD, OpenBSD, Solaris, Windows

    C, C++, PHP, VB6, ASP, VBScript, JavaScript

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    
    using namespace std;
    
    void main() {
        string sText = "Hello!";
        {
            ofstream OutFile("myfile.txt");
            OutFile << "Text: " << sText << endl;
        }
        {
            ifstream InFile("myfile.txt");
            InFile >> sText;
            cout << sText << endl;
        }
    }
    I think that should compile...you get the idea though
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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