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)
For example:
Code:[TestScript] Username=test/test@Testdb Form=Start #Form = Test Otherparams=szendtime=13:00 PageTitle=Hello [TestScript_2] Username=test2/test2@Testdb2 Form=Start #Form = Test Otherparams=szendtime=14:00 PageTitle=Hello
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.
i hope anybody could help meCode:#include "stdafx.h" #include <iostream> #include <fstream> #include <string> using namespace std; int main() { long v_nBegin,v_nEnd; float v_nProzentSatz = 1; char cline[255]; string sline; ofstream ConfigFile ("Config\\Config.txt"); ifstream myfile ("Config\\example.txt"); if (myfile.is_open()) { while (! myfile.eof() ) { getline (myfile,sline); strcpy(cline, sline); for(int i = 0; i <= 255; i++) { cout << cline[i]; }; } myfile.close(); } else cout << "Unable to open file"; cin.get(); return 0; }



LinkBack URL
About LinkBacks



