Hello! My name is Matt.
Disclaimer: Don't mind my primitive syntax; there is a limited amount of C++ that I actually know.
Preface: I have a function that goes through a .txt and finds a certain line. I do this by formatting my .txt very specifically (as below).
[encriptions.txt] //not actually encripted ... yet
1 2 3 4 5 6
|
00
basepassword;password
ext1:ex
ext2:mr
ext3:nj
ext4:tt
|
The '00' and the ';'/':' are used on other parts of the program.
Note the ' ' at the end of each line after the first.
Goal: to print out a numbered list of the password titles only (success) and prompt the user to remove one, confirm that the user is removing the correct one (where my code goes awry), and finally remove it (didn't get there yet).
Ifile.seekg(4L,ios::beg); gets me to the beginning of the second line (base ...)
and I use it for a while loop with Ifile.get(x); (x is a declared char) to cout<< successfully. The user is them prompted for the one to remove. This all works very well.
To comfirm the choice, I want to have a statement say "Really remove xxxxx from the list?" I use Ifile.seekg(4L,ios::beg) again, and Ifile.get(x); to navigate in the file to the beginning of the line with the user's choice in it. Ifile.tellg(); returns a 4 so I know the seekg() is working. The problem now is all of the Ifile.get(x); used after the list is printed return as spaces (' '). This has baffled me, two professors, and several savvy friends of mine.
Things I've tried
- closing and opening the file again
- cout<<ing the value of x at decisive points to confirm that Ifile.get(x); always reutns a space.
- I've tried using Ifile.sync(); to flush the buffer, failed (yielded -1)
- Google has not been of much help, with the exception of it landing me here
Because I really can't advance the program until I get past this, I will be checking this several times a day, so don't be a afraid to ask for more info. If seeing the function would help, I'll gladly post it up. I'll keep it updated as well.
Thanks in advance,
Matt