Article View: borland.public.cppbuilder.nativeapi
Article #6883Re: cout <<"HELP" << endl; How to redirect all cout to a Memo ?
From: Seime Nuse
Date: Wed, 30 Mar 2005 19:16
Date: Wed, 30 Mar 2005 19:16
37 lines
2157 bytes
2157 bytes
> Using "cout" for debugging, logging is very easy and flexible when running
> in console applications.
>
> cout <<"HELP" << endl;
>
> How to redirect all cout to a Memo ?
>
Following code is not right answer but may help a bit. You can create a
console by clicking on Button2. The Button3 will show you that all cout will
go to the console. and finally Button4 will close the console. BUT if you
close the console directly instead of closing it via Button4, then your
system will crash (I do not know how to prevent this)
//---------------------------------------------------------------------------
#include <stdio.h >
#include <iostream>
FILE *mF;
void __fastcall TForm1::Button2Click(TObject *Sender)
{
AllocConsole();
SetConsoleTitle("Your title here");
mF = freopen("CONOUT$", "wb", stdout);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
std::cout <<"Hello"<< std::endl;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
fclose(mF);
FreeConsole();
}
//---------------------------------------------------------------------------
Technical Details
Message-ID:
<424afb34$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<424ad7c1$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,70264b2d092f1bae X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: <Seime Nuse> Newsgroups: borland.public.cppbuilder.nativeapi References: <424ad7c1$1@newsgroups.borland.com> Subject: Re: cout <<"HELP" << endl; How to redirect all cout to a Memo ? Date: Thu, 31 Mar 2005 05:16:40 +1000 Lines: 39 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 211.30.60.151 Message-ID: <424afb34$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1112210228 211.30.60.151 (30 Mar 2005 11:17:08 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail