Thread: Reading and Writing

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    72

    Reading and Writing

    how do i read and write to a .txt file? and code/tutorials would be greatly appreciated.

  2. #2
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    I'd suggest that you go to google and search for "C streams".

    That should help you.

    ::edit
    ::sorry, I didn't see this was the c++ board
    ::You could still google,
    ::but this time search for "C++ streams"
    Last edited by The Dog; 10-06-2002 at 10:15 AM.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Look up these functions in a C/C++ reference.

    open()
    read()
    write()
    close()

    Kuphryn

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Code:
    ofstream WriteFile;
    WriteFile.open("MyFile.txt", ios::out);
    if(!WriteFile.fail())
    {
       WriteFile << "Hello world!" << endl;
       WriteFile.close();
    }
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    ... or the tutorial based on this site:
    http://www.cprogramming.com/tutorial/lesson10.html
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  6. #6
    Banal internet user
    Join Date
    Aug 2002
    Posts
    1,380
    ... or you could read the faq!

    So many options....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 03-05-2009, 03:14 AM
  2. accessing my com port, writing and reading data
    By shoobsie in forum C Programming
    Replies: 7
    Last Post: 09-16-2005, 03:29 PM
  3. Reading from and writing to same file
    By Strait in forum C++ Programming
    Replies: 2
    Last Post: 02-01-2005, 04:37 PM
  4. file writing and reading
    By Micko in forum C Programming
    Replies: 8
    Last Post: 01-13-2004, 11:18 AM
  5. reading and writing structures to pipes
    By netwizio in forum Linux Programming
    Replies: 3
    Last Post: 01-06-2004, 01:28 AM