Rename the Console Window

How to you rename the console window from "C:\Documents and Settings\*name*\Desktop\etc.." to say.. "Adventure Game" or something?
You can make it with system() command, but usage of system() is not suggested . So don't use it if you don't need to.
 
system( "Title Adventure Game" );

I don't know any other way to do it. If there's any , you should use that way.
Last edited on
1
2
3
4
5
6
7
#include <windows.h>

int main()
{
  SetConsoleTitle("Adventure Game");
  // more code...
}


~psault
Psault, I get the error,

[code=cpp]1>c:\documents and settings\brad\desktop\coding files\cpp projects\test_01\test_01\main.cpp(6) : error C2440: 'initializing' : cannot convert from 'const char [15]' to 'int'[/code]

with that code.
Last edited on
Cheesy, which compiler are you using??? I tried, Psaults code works with Dev(not only with dev).
He keeps compiling with UNICODE, so he needs to use some Windows macros around his string literals...
1
2
3
4
5
6
7
#include <windows.h>

int main()
{
  SetConsoleTitle( TEXT( "Adventure Game" ) );
  ...
}
Last edited on
Well I'm using VC++ 2008 Express, should I be using something else...? (Also something wrong with unicode?)

PS: Thanks again Duoas! :)
Last edited on
I think,VC++ is fine. About unicode, Duoas knows better.
Meaning...? O.o
Topic archived. No new replies allowed.