I want to know how to seek to a point in a file.
Example I have a database program with a text file named "info.txt"
There are two lines in it:
Password = user makes password
Activated = true/false

How do I make the program find if they have activated the program yet, and then find the password.

Thanks for your help.

if your file looks just like the example you give, why not read each line into separate strings. If the second string has the value you interpret as activated, then use the password found in the first.

Thanks for your help,
How exactly would you do that.
I am new to finding parts of files.
Could you post a little example, thanks.

"finding parts of files."

No, not finding parts of the file but read the whole file, while
analyzing it in the process.

Assuming the file is the something like this :

Info.txt
---------------------------------------------
Password = hello_world
Active t = false
---------------------------------------------
1) open up a file with fstream
2) read first line into string
3) increment the string until it reaches the equal sign, then the password something like this :

while( *stringVariable++ != '=' ) ; //increment until the = sign
while( ! (isalpha (*stringVariable++) ) ); //increment untill you reached the first letter in the password.

4) Now you have got the password. save it.
5) read the next line. do the same process like in # 3
6) compare stringVariable to flase or true. Set bool variable
accordingly.

7) Continue with the rest of your program.

Thanks I will try that, it makes sense now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.