Console Applications

I created a project in batch called BitCrypt that ciphered text with multiple caesar, reversal, subtitution, and other ciphers. I'm trying to figure out how to make them in C++. Any suggestions?

And also, I'm creating a simple ASCII game. Is there a way to utilize <ctime> to add to a variable over time? (The game is about money making in a burger shop :/.)

Another thing: how do you include photos (PNG) in a console window?

Sorry if this doesn't make any sense, I'm a n00b.
Any suggestions?

Nothing you don't already know. Learn C++, write the code.

Is there a way to utilize <ctime> to add to a variable over time?

Yes, although a better way would be to simply have a repeating delay trigger an increase in the variable.

how do you include photos (PNG) in a console window?

A console is for outputting characters. If you want to show images, you'll need to generate a window capable of that kind of graphics. C++ has no built-in understanding of images, windows, hardware, anything like that. This is provided by your operating system, and C++ essentially asks your operating system to do it via a set of provided functions.
Last edited on
Do you happen to know how to write and link resource files (.RC) to my program. I'm running W7 with Code::Blocks 10.05.
Last edited on
Not a clue. This is how I display a png image in a window, using the CImg library:

1
2
3
4
5
6
7
8
9
10
#include "CImg.h"
#include <iostream>
using namespace cimg_library;

int main()
{
  CImg<float> image("hills.png");
  CImgDisplay main_disp(image);
  std::cin.ignore();
}
Obligatory link:

http://www.cplusplus.com/forum/articles/28558/


If you want to display images, you do not want the console. You can hack it up to make it work, but it will be far more difficult than just using a normal window.

Look into graphic libs. SDL, SFML, and Allegro are all very popular.

SDL is a bit less flexible, but is very easy for beginners to set up and use.
SFML is more powerful, but is more difficult to set up.
I don't have any firsthand experience with Allegro.
Last edited on
Thanks Disch. Okay I have this RC code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
MAINICON ICON "Installer.ico"


1 VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 0,2,7,0
FILEOS 0x4
FILETYPE 0x1
{
BLOCK "StringFileInfo"
{
	BLOCK "040904E4"
	{
		VALUE "CompanyName", "HackSoft, LLC."
		VALUE "FileDescription", "BitCrypt Cipherer"
		VALUE "FileVersion", "1.0"
		VALUE "InternalName", "BITCRYPT"
		VALUE "LegalCopyright", "Copyright (C) 2012 HackSoft, LLC."
		VALUE "LegalTrademarks", "None"
		VALUE "OriginalFilename", "BitCrypt.exe"
		VALUE "ProductName", "BitCrypt v0.27b3"
		VALUE "ProductVersion", "1.0"
		VALUE "Comments", ""
	}
}

BLOCK "VarFileInfo"
{
	VALUE "Translation", 0x0409 0x04E4
}
}




Now what do I have to do to include it and make it appear in Windows?
I believe you just pass the resource file to the resource to be compiled. Then you can access the resources in your code by using whatever symbol names you gave them. In Code::Blocks, the resource compiler arguments can be found in the "Build Options" of your project.
What? I don't think I understand. So I go to Project < Build Options...

Then what?
Project -> Build Options -> Search Directories (its a tab) -> Resource Compiler -> Add -> Fine the rc file you want.
I have this Vigenere Cipher code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
#include <stdlib.h>
#include <cstdlib>
#include <windows.h>
#include <string.h>

using namespace std;

int main()
{
    string keyword;
    string msg;
    int crypted;
    int real_difference;
    int i=0;
    int k;
    int l;

    cout<<"Enter the keyword : ";
    getline(cin, keyword);



        cout<<"Enter the message you want to crypt : ";
        getline(cin, msg);

        k = keyword.length();
        l = msg.length();

        loop1:
        if(k < l); //used to even out the keyword and the sentence
        {          //to change each letter
               keyword = keyword + keyword;
               k = keyword.length();
               if(k < l)
               goto loop1;
        }

                cout<<"\n\n";
                while (i<= msg.length()) //records length and uses string as array
                {
                        keyword[i] -= 'a'- 1;


                        if((msg[i] + keyword[i]) > 'z') //If crypted letter goes beyond 'z'
                                crypted = 'a' + (keyword[i]+msg[i] - 'z') - 1;

                        else if(msg[i] == 32) // If letter is a space
                                crypted = msg[i];

                        else
                        crypted = msg[i] + keyword[i]; //Crypting


                        cout<<(char)crypted; //Prints out the crypted letter
                        i++;

                        if(i>= msg.length())
                        break;
                }




        return 0;


        }


How do I reverse the process to decrypt it?
Didn't you just ask this on Hackforums? If you are going to be releasing it to Hackforums then you shouldn't be asking for code here.
Last edited on
Well I'd assume there's different people here that can offer different help. Can't I just give credit to the ones who create the code? It's only a release here and on HF.
The encrypt function and the decrypt function are the only two functions in the program. They are doing all the work while you just add 'getline(std::cin, str)' to your program. I just don't see the point of releasing a program when 90% of the code was written by someone else.
Once I have learned how to cipher text with IFs, FORs, WHILEs, and possibly more, I will code more cipher to give more cipher strength. BitCrypt isn't just a Vigenere, it's many ciphers put into one. Have you not looked on the BSDaCLI thread of the original BitCrypt?
Last edited on
So I'm making a game. Is there a way to move the character on the screen using <conio.h>? I think there is but I don't know how. I want it to be like the CHOICE command in MS-DOS Batch.
Topic archived. No new replies allowed.