How to make a vector permanent to the memory
I wany to have an input and push it to the vector then run the programe and after closing the programe how I could output the same thing which I inputed previously? I was wondering to make the vector static with static keyword but it doesn't workded...... Please help....and one thing.... I think this question needs no code cause even I am so confused that how I could make such programe
8/8/2020 1:02:04 PMGorom_Pani
11 AnswersNew Answer
Just add all the inputs in a file (maybe txt) I don't know C and C++ so I can't show you a code related to that But I know python! I can show you an example! Do you want?
codemonkey I wanna make this happend in SoloLearn But is it possible in SoloLearn....And also How nova have done those things.....please explain
codemonkey Can you tell me how I could do that with files and plz give me the code to understand clearly
codemonkey I wanted to create a namelist....... I wanted to add every name in a vector and keep it on the memory permanently......and everytime the viewer enter a name I could push the name in the vector and make it parmanent in memory
There is no way to save data to memory when the program exits. Once the program exits, the data will be lost. You will need to save the data to a file before the program closes. Then when you open the program you can import the data again
codemonkey I have read this but how I could detect every name in the file?
codemonkey How I am gonna read each line.....besides in C++ tutorial there is no function which can do that
AteFish, file handling was covered in the C++ Tutorial, which you have completed. See: http://www.cplusplus.com/reference/iolibrary/ (C++) http://www.cplusplus.com/reference/cstdio/ (C/C++)
Basic example with some useful links: https://code.sololearn.com/cxkl7hITXLFj/# Take a look at https://github.com/goblinhack/c-plus-plus-serializer, a header only serializer Otherwise use a database, e.g. http://srombauts.github.io/SQLiteCpp/
codemonkey Please scroll up and see What I wanted to do and I also use codeblocks