tags:

views:

166

answers:

4

How to set the console window title in C?

printf("%c]0;%s%c", '\033', "My Console Title", '\007');

This works only under linux, not in windows, Does anybody know a "cross-platform" solution? (of course not "system ( title=blah )")

A: 

Sounds similar to this posting: (Which is for Java, but the accepted answer uses JNI [ie a C Native call].

http://stackoverflow.com/questions/994273/how-to-change-command-prompt-console-window-title-from-command-line-java-app

monojohnny
This will need java though,
Levo
Shouldn't need Java - the Java in the posting is simply 'wrapping' a C library (JNI).
monojohnny
+5  A: 

windows.h defines SetConsoleTitle().

You could use that everywhere, and declare your own function for linux platforms that does the same thing.

Anon.
+1  A: 

You can do this by calling SetConsoleTitle.

Reed Copsey
+1  A: 

Maybe you have to implement a "cross-playform" solution yourself.

For windows 2000+, you can use SetConsoleTitle(), more imformation can be found on MSDN.

XUE Can