Need help regarding saving variables via fstream, do I need to use vector?

后端 未结 2 1194
我在风中等你
我在风中等你 2021-01-25 22:08

I doing this project, where I want to save some variables for a device; Devicename, ID and type.

bool Enhedsliste::newDevice(string deviceName, string type)
{
fs         


        
2条回答
  •  情话喂你
    2021-01-25 22:32

    To delete a line from your current text file, you will have to read in all lines, e.g. storing the data in a std::map, remove the relevant item, and write it all back out again. An alternative is to use a database or binary fixed size record file, but reading everything into memory is common. By the way, I would remove the ios::app append mode for opening the file for reading. It translates to the equivalent of append mode for fopen, but the C99 standard is unclear on what it means for reading, if anything.

提交回复
热议问题