hello !! I have a doubt. how to develop a software in c++?? i know it should be done through program. but how can i develop it into a software which runs like the dos counter-part of eclipse or winap or media player or anyother software. i mean how can i make the program to remember the value the user assigned to its variables without erasing it everytime i close the exe file running the program?? hope u undertand my question..

5 Years
Discussion Span
Last Post by arunkishorres

Given that "how to develop software" is extremely broad, I'll answer the specific question you asked.

how can i make the program to remember the value the user assigned to its variables without erasing it everytime i close the exe file running the program??

Persistant data would be saved to the hard drive or some other semi-permanent storage and then loaded back into memory when the program is run again.

Edited by deceptikon

Votes + Comments
you said it in a fancier fashion then I ever could. nice

can u please tell me how that can be done??? saving an reterieving from a hard drive??


I'm having trouble thinking of a programming language that doesn't support reading and writing files. C++ certainly supports it. Click on this link for us professionals' secret database of arcane knowledge.

Edited by deceptikon


As simple as this:

#include <iostream>   // to print to console
#include <fstream>    // to read / write to a file
#include <string>     // to represent words (strings)

int main() {

  std::ofstream output_file;
  output_file.open("test.txt");       // open a file for outputting to it.

  std::string data = "Hello World!";  // create some "data" to be written

  output_file << data;                // write the data.

  output_file.close();                // close the file.

  std::ifstream input_file;
  input_file.open("test.txt");        // open the file for input.

  std::string data_from_file;         // create some place to put the data in.

  getline(input_file, data_from_file);// read one line from the file.

  input_file.close();                 // close the file.

  // finally, write the result on the console:
  std::cout << "Received this data from the file: " << data_from_file << std::endl; 

  return 0; // everything went well! Return value of 0.

You could easily split the reading and writing parts into two separate programs and you have what you asked for. For more info, read this tutorial.


@decepticon and @mike....thank u guys for replying to my doubt...but i dont have any problem with file handling or input and output operation in file... but to have a permanent storage of an variable, say char[] a, which should ask the value from the user the first time the prgm is run, then accept the value given and store it permanently without getting erased when the console is closed such that 'a' can be used with its original value in any number of times the program is run.


I don't think you're making the connection here. You write the variable's value to a file to store it before the program ends. Then when the program starts back up, you read the value back into a variable. That's all there is to it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.