简体   繁体   中英

c++ saving datas .txt file as a class

i'm studing on file operations (c++) and i came to a deadlock

i can read datas from a file but i want to put some rules. for example my .txt file is:

<play
**guitar = "false"
**clarinet = "true"
>

<clairnet

**color = "black"
**type = "g"
>

i want to reach clarinet.color and may be change later. i wrote too long codes, i can reach it now. (reading the file character by character and searching for "clarinet" first, when it found it, it start to search color from the "clarinet" line. when it sees color start to search for "=" then gets all the line since = and strtok by ""s.)

it's hard for the hardware and me :')

and the main problem is changing the value. i copy all file except the value, change the value and write all to the file again.

i need to save all datas like a class to the file, like using mysql with php.

how can i do it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM