A
A
Andrey Gostishchev2014-08-03 18:41:08
Programming
Andrey Gostishchev, 2014-08-03 18:41:08

Why is this happening and where is the error?

I am writing a password manager in C++. He has a settings file, which initially contains 0, which means that the person has not yet entered the password vault.

Here
conf.open("config.txt");
  conf >> con;
  conf.close();
  if (con == 0){
    firstlaunch();
  }


check for the first input.
Here
conf.open("config.txt", ios_base::out);
  conf << 1 << endl;
  conf.close();


0 is replaced by 1, they say the person has already entered. But even if this file is 1,
it runs the first run function:
here
4fa4ed529bda4a3ca03ccab614c62eaf.PNG
.
UPD: this happens sometimes, although I don’t touch a piece of code with a check.
Tell me, where is the error?
add. question
with such inclusions
#include "stdafx.h"
#include <iostream>
#include <time.h>
#include <fstream>
#include <string>
#include <Windows.h>

cout, cin, system statements become errors
So
1a89e6dbe2444cbab03ed1e3c06598d8.PNG

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bogolt, 2014-08-03
@MERCH_music

So, now try to improve your question so that it can be answered.
1. A screenshot of a running application is great, but it's not clear why it is needed.
2. Screenshot of a piece of errors - it's not clear what kind of errors there are. Figure out how to copy the build log from the studio and get these messages out of there.
3. After reading from the file, check the value of the con variable and display it on the screen to make sure that the wrong number is being read from the file.
If there is not the right number, then check the type of this variable - maybe you wrote char "1" there and read it already as int or vice versa.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question