Thread: Saving to a .txt file

  1. #1
    Registered User
    Join Date
    Dec 2005

    Saving to a .txt file

    Hi, I need some help getting this to work right. I get errors with the last few lines of my code. It works like this or should work like this:
    1st if say doesnt = anything then(else) save this to a file
    2nd open file
    3rd look in file for whats in side, then that will be saved to a string
    4th learn=line+say+nothing+learn+whitespace
    5th save "learn" to file
    6th close file
    last restart loop of my programe

    Thats about it on how it should work, this what error I get is: no matching function for call to `getline(std::string&, std::string&)' hope you can help out, thanks if you can or point out if I made a mistake some where.

    string say;
    string line;
    string learn;
    string learnfile = "learn.txt";
    string nothing = ": ";
    string whitespace = " ||";
    //more code in middle here
        else{cout<<"Hmm, I must not have this in my data yet, can you plez tell me what this word means?"<<endl;
            getline(cin, learn);
            ifstream learnfile;
            ofstream myfile;
            while (getline(learnfile, line))
              myfile << learn;
            learnfile.close ();
            cout<<"Saved, thanks for your help on making me better."<<endl;}}}//end of code

  2. #2
    Registered User
    Join Date
    Dec 2005
    Nvm^^; I got it wow, took me forever to get thisO.o; um you can delete this if you like^^;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  3. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  4. read from .txt file & put into array?
    By slow brain in forum C Programming
    Replies: 6
    Last Post: 02-25-2003, 05:16 AM