So, I'm working on making a encrypted in C++, just a basic one. The encrypter needs to have a minimum character limit but it's not working. It's not coming up with any compiler errors, but instead just acting as if the if statement isn't there...

#define _WIN32_WINNT 0x0500
#include <iostream>
#include <windows.h>
#include <string>
#include <fstream>

#define KEYDOWN(vk) GetAsyncKeyState(vk) & 0x8000
#define cls system("cls")
using namespace std;

int main()
{
    HWND hWnd = GetConsoleWindow();
    string Estring;
    ofstream encrypted;

    cls;
    cout << "\t\t\t\t[F1] - Encrypt" << endl;
     while (1) {
        Sleep(1);

        if (KEYDOWN(VK_F1)) {
            cls;
            cout << "Enter the string you would like to be encrypted..." << endl << endl;
            cout << "::  ";
            cin >> Estring;
            if (Estring.size() < 8) {
                                      ....
                                    }
            else {
                                    return main();
                              }
    cin.get();
    return 0;
}

What is the problem here?

line 31: Never ever for any reason call main() from any part of a program. In the example you posted use a loop.

line 23: what is cls? That line doesn't make any since at all.

line 31: Never ever for any reason call main() from any part of a program. In the example you posted use a loop.

line 23: what is cls? That line doesn't make any since at all.

Okay, I'll keep that in mind.

#define cls system("cls")

Makes it a little easier, that way I don't have to type as much.

Now could someone answer my question? I'm not getting any compiler errors. The if statement is just being ignored.

The problem is on line: 27. It just ignores it as if it was not there.

this code has alot of issues so please if you donot want to paste all of your code (that is better) start with simple example that can compile
and what is sleep(1)?? sleep for 1 mille sec

Edited 4 Years Ago by mazzica1: n/a

This article has been dead for over six months. Start a new discussion instead.