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.

8 Years
Discussion Span
Last Post by kernel>panic

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 :

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

7) Continue with the rest of your program.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.