Hi, I have been doing c++ for about a month and a half and have done 26 tutorials on Youtube and I feel rather proud of learning something I have wanted to do since I was 13 (I'm 20 now) and that is to program. Back to the point. I know a console title can be done with system("title windowname"); but I want to have one that is portable and the stupid firewall (Comodo) asking me to give it permissions. cin.get(); has stopped the firewall were had it wouldn't if I put system("PAUSE");

What I am saying is: is there an alternative to system("title windowname") I'm pretty sure its not portable and I am trying to make my code as portable as possible, to set me in good habits.

Thnx in advance!!

Re: Console Title 80 80

There is not a portable way to set a window title. The best you can do is have something like a appsys.h header with all of the non portable stuff:

#ifndef APPSYS_H
#define APPSYS_H

bool ChangeConsoleTitle(const char *title);

#include <windows.h>
#include "appsys.h"

bool ChangeConsoleTitle(const char *title)
    // windows API
    return SetConsoleTitle(title);

This separates the non portable code from the portable code. In the portable code, call ChangeConsoleTitle and when porting to a new system, just change the definition of ChangeConsoleTitle.

Re: Console Title 80 80

I suppose non-portable was to be expected with each operating sytem with different things I guess thanks for your help and I have learnt something new yet again!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.