0

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?

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by mazzica1
0

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.

0

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.

0

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 by mazzica1: n/a

This topic has been dead for over six months. 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.