Thread: using varaibles to store data?

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    18

    using varaibles to store data?

    ok so I wanna use varaibles to store data. The thing is I wanna use the Cin >> input so that everything people type in is stored in the program. I understand that you can allow users to type in info and store the info in varaibles. Im making a artificial intelligence program and I want certain info to be stored in certain parts of the program. Lets say for example I want some info people type in to go to say the "long Term memory database" while I want other info to go to the "short term memory database." Can I do this using variables alone? Sorry im new to C++. Thanks

  2. #2
    Registered User
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    267
    i'm guessing you want the data to stay after the program closes. The best way i know if is store all of it in a text file.

    OS: Windows 7, XUbuntu 11.10, Arch Linux
    IDE: CodeBlocks
    Compiler: GCC

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    18
    how do I store it in a text file, what would this method be known as? Sorry im still learning.

  4. #4
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Use an fstream.
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  5. #5
    Registered User
    Join Date
    Nov 2006
    Posts
    18
    thanks manutd. What exactly does a fstream do? Im a little confused.

  6. #6
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    If you understand cout, it's like that. It's something called a buffer. The << operator puts its left operand (the text) into it's right (your file). When you flush the buffer, it outputs the text.
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  7. #7
    Registered User
    Join Date
    Nov 2006
    Posts
    18
    thanks manutd. I will try it out.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. singly linked circular list
    By DarkDot in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2007, 08:55 PM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. data read and store
    By jammi in forum C++ Programming
    Replies: 1
    Last Post: 12-30-2002, 04:39 PM
  4. C Programming Question
    By TK in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 07-04-2002, 07:11 PM
  5. Do you store store one off data arrays in a class?
    By blood.angel in forum C++ Programming
    Replies: 5
    Last Post: 06-24-2002, 12:05 PM