Parsing File

Hello Everybody,

i'm happy to be here and i say hello to all

I have a Poblem. I wont to open a File in c++, Parsing it and then close the file. The goal is. I have a file where some configuration are defined and i want to get differnt parameters, store it in an other file (because i dont need them all)

so i want to pars the file and start when the programm "see" this [....] (so i know there is a new config part). i want to get only the username, the other stuff i dont need. The programm should also store the username in an other file

The Programm should also know if there is a #, it should jump to the next line.

when the next [] comes it should start again to get the username and store it in an other file and so on.

i have this now. It is not much but i have a problem to convert the string to a char.

If you ever want to turn std::string to a c-string just use the c_str() method, like

Code:

cline.c_str();

no need to copy.
Also, strcpy() is a c-function. You just use "=" with std::string. And note that it is wrong the way you use it. You don't include string.h and the parameters of strcpy are wrong as well.

The second thing is that you can simply do this

Code:

cout << cline

instead of using a loop. The way you use the loop is a bit wrong as well. You would do this with a c-string, printing only the useful information