Reputation:
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 )
)
Upvotes: 8
Views: 13877
Reputation: 7695
The most easy way to achieve this in C is to use windows.h header and use the SetConsoleTitle function
#include <stdio.h>
#include <windows.h>
#include <conio.h>
int main()
{
HANDLE handleConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTitle("Mini Desktop App"); // Here add the title of the window
while(1){
printf("Works as expected\n");
printf("Press any Key to exit :)\n");
getch();
break;
}
return 0;
}
Upvotes: 0
Reputation: 701
Maybe you have to implement a "cross-playform" solution yourself.
For windows 2000+, you can use SetConsoleTitle(), more imformation can be found on MSDN.
Upvotes: 0
Reputation: 59993
windows.h
defines SetConsoleTitle()
.
You could use that everywhere, and declare your own function for linux platforms that does the same thing.
Upvotes: 6
Reputation: 6181
Sounds similar to this posting: (Which is for Java, but the accepted answer uses JNI [ie a C Native call].
How to change command prompt (console) window title from command line Java app?
Upvotes: 0