Thread: recall

  1. #1
    Registered User
    Join Date
    Apr 2003

    Question recall

    hay, does anyone out there know how to pull info out of a .txt and insert it into a program? I have tried to read a since integer from a .txt and then make that equal a variable in my program ,but it never works... any ideas? thanks

  2. #2
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    goto the tutorial and look at the section about ifstream and ofstream

  3. #3
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Like writing and reading to files?

    Here is some sample code:
    #include <fstream> // File stream, you need this
    #include <iostream>
    using namespace std;
    int main()
    fstream file("somefile.txt", ios::out | ios::binary); // Opened somfile.txt for output mode and binary mode for write function
    int stuff;
    cout << "Enter stuff: ";
    cin >> stuff;
    file.write((char*)stuff,sizeof(stuff)); // write to the file
    file.close(); // Close the file
    return 0;
    That was really simpe, but I hope it kind of helps. Maybe check the FAQ?
    If you ever need a hug, just ask.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Absence of Visual Recall
    By Davros in forum A Brief History of
    Replies: 2
    Last Post: 10-24-2002, 01:27 PM
  2. Pixel Shaders.
    By Cheeze-It in forum Game Programming
    Replies: 1
    Last Post: 05-21-2002, 01:16 AM
  3. Replies: 17
    Last Post: 04-09-2002, 04:37 PM