How do I name a basic .exe console?

Hello everyone.

I am VERY new to C++. I want to make 2d games, but I want to learn all the basics first. (I only want to learn to make games and stuff :P)

So I have a basic calculator going on here. So, when I run the .exe file (if I ever want to make it downloadable or something), the title of the program is the directory it's in. How can I name the window to something like "Basic caluclator"? Thanks!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  #include <conio.h>
#include <iostream>
using namespace std;
int main(){

    int a;
    int b;
    int c;

cout << "Enter the first number \n";
    cin >> a;
    cout << "Enter the second number \n";
cin >> b;
    c = a + b;

    cout << "The answer is: " << c << endl;

   getch();
return 0;


}
closed account (E0p9LyTq)
How can I name the window to something like "Basic caluclator"?

Depends on the operating system.

For Windows you can use the SetConsoleTitle function:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms686050%28v=vs.85%29.aspx

There is an example at the link.
Last edited on
@FurryGuy

I am confused, please give an example. I don't want to add TONS of code to make the console program name something like "calculator" :P
Just got it! For anyone who also has this problem:

You have to include <windows.h>, so like this;

#include <windows.h>

then do this:

SetConsoleTitle("NAMEHERE");

Thats all! :)
Topic archived. No new replies allowed.