Click here to Skip to main content
15,888,113 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: CASE SOLVED AND CLOSED cout and cerr execute out of coded sequence Pin
Richard MacCutchan22-Dec-19 22:55
mveRichard MacCutchan22-Dec-19 22:55 
QuestionSOLVED CASE CLOSED cout in color and perror - revisited Pin
Vaclav_20-Dec-19 4:46
Vaclav_20-Dec-19 4:46 
AnswerRe: cout in color and perror - revisited Pin
leon de boer20-Dec-19 5:01
leon de boer20-Dec-19 5:01 
GeneralRe: cout in color and perror - revisited Pin
Vaclav_20-Dec-19 5:48
Vaclav_20-Dec-19 5:48 
AnswerRe: cout in color and perror - revisited Pin
Richard MacCutchan20-Dec-19 6:07
mveRichard MacCutchan20-Dec-19 6:07 
GeneralRe: cout in color and perror - revisited Pin
Vaclav_21-Dec-19 3:10
Vaclav_21-Dec-19 3:10 
GeneralRe: cout in color and perror - revisited Pin
Richard MacCutchan21-Dec-19 3:34
mveRichard MacCutchan21-Dec-19 3:34 
GeneralRe: cout in color and perror - revisited Pin
Vaclav_21-Dec-19 9:05
Vaclav_21-Dec-19 9:05 
Unfortunately that is not a solution.

Edited
perror always prints in red - using stderr / cerr .
Maybe I should just switch from cout to cerr to output in red,


Please observe that escape codes, which are still ignored, are printed instead of being reacted on.

That is THE ISSUE, the usage of while is NOT related to the issue at all.

I believe this is related either to complier or operating system.
I am searching for a solution in that direction for now.

Any other suggestions are welcome.

C++
cout << "Function: " << __FUNCTION__ << endl;
cout << " START test area " << __LINE__ << endl;
errno = 0;
perror("TEST perror "); // default print in red
perror("\033[1;31mTEST perror "); // print the error details in red
cout << "\033[0m\n";              // restore to standard colours
errno = 5;
perror("\033[1;31mTEST perror ");
cout << "\033[0m\n";

printf("%c[%dmHELLO!\n", 0x1B, 32);
const std::string red("\033[0;31m");
cout << red << "red text" << endl;

system("Color 1A");
system("Color 1B");
std::cout << "\t\t\t    Hello World" << std::endl;

cout << "Bluetooth client " << endl;

cout << " START test area " << dec << __LINE__ << endl;
cout << __FUNCTION__ << endl;


Function: main
 START test area 39


HELLO!
red text
TEST perror : Success
TEST perror : Invalid argument
TEST perror : Input/output error
sh: 1: Color: not found
sh: 1: 			    Hello World
Bluetooth client 
 START test area 58
main
set color @line    443
set color @line    449
PROGREESS TRACE START 


modified 21-Dec-19 15:38pm.

GeneralRe: cout in color and perror - revisited Pin
Richard MacCutchan21-Dec-19 21:25
mveRichard MacCutchan21-Dec-19 21:25 
QuestionHow to close file in C++? Pin
Vaclav_19-Dec-19 17:13
Vaclav_19-Dec-19 17:13 
QuestionRe: How to close file in C++? Pin
CPallini19-Dec-19 21:35
mveCPallini19-Dec-19 21:35 
AnswerRe: How to close file in C++? Pin
Stefan_Lang19-Dec-19 21:59
Stefan_Lang19-Dec-19 21:59 
AnswerRe: How to close file in C++? Pin
Vaclav_20-Dec-19 4:51
Vaclav_20-Dec-19 4:51 
AnswerRe: How to close file in C++? Pin
Richard MacCutchan19-Dec-19 21:56
mveRichard MacCutchan19-Dec-19 21:56 
QuestionDo "setw(offset) " BEFORE cout ? Pin
Vaclav_18-Dec-19 4:22
Vaclav_18-Dec-19 4:22 
AnswerRe: Do "setw(offset) " BEFORE cout ? Pin
Richard MacCutchan18-Dec-19 4:56
mveRichard MacCutchan18-Dec-19 4:56 
AnswerRe: Do "setw(offset) " BEFORE cout ? Pin
leon de boer18-Dec-19 5:19
leon de boer18-Dec-19 5:19 
GeneralRe: Do "setw(offset) " BEFORE cout ? Pin
Vaclav_19-Dec-19 17:26
Vaclav_19-Dec-19 17:26 
GeneralRe: Do "setw(offset) " BEFORE cout ? Pin
Richard MacCutchan19-Dec-19 21:50
mveRichard MacCutchan19-Dec-19 21:50 
AnswerRe: Do "setw(offset) " BEFORE cout ? Pin
CPallini18-Dec-19 10:43
mveCPallini18-Dec-19 10:43 
GeneralRe: Do "setw(offset) " BEFORE cout ? Pin
Vaclav_19-Dec-19 17:14
Vaclav_19-Dec-19 17:14 
QuestionLoadString Pin
Member 1450258316-Dec-19 23:36
Member 1450258316-Dec-19 23:36 
AnswerRe: LoadString Pin
Daniel Pfeffer16-Dec-19 23:44
professionalDaniel Pfeffer16-Dec-19 23:44 
AnswerRe: LoadString Pin
Richard MacCutchan16-Dec-19 23:47
mveRichard MacCutchan16-Dec-19 23:47 
QuestionLoadImage Failure Pin
ForNow15-Dec-19 14:17
ForNow15-Dec-19 14:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.