Page 1 of 1

C++ Borland Compiler

Posted: Mon Jun 23, 2003 2:58 am
by nakahisman
I start using Borland Command Line Compiler with TextPad. But when I
write programs use "cin" to read console entry, output in the textpad is not sohwn. Like:
int a;
cout<<"Enter a unmer";
cin>>a;
cout<<"You Entered"<<a;

When I run this in console it works , but when I run this in textpad , it does not let me enter a number and it directly writes the
You Entered 8069560

Posted: Mon Jun 23, 2003 8:26 am
by bbadmin
It is not possible for a Windows application to redirect the standard input of a console application. Whe you add a tool to TextPad's menu that reads from stdin, make sure that Capture output is not checked. It will then run in its own console window.

Keith MacDonald
Helios Software Solutions

C++ Borland Compiler

Posted: Tue Jun 24, 2003 3:04 am
by nakahisman
Thank you very much for the reply, I unchecked the capture output,
but this time after I put the value that cin will read, when I hit enter console disaapears

Re: C++ Borland Compiler

Posted: Mon Jul 07, 2003 8:43 pm
by Drxenos
Also, you should keep in mind when writing C++ code that the runtime is not required to immediately output your text when sending data to a stream. So, if you want to guarantee that the text you send to cout gets displayed before it waits for input from cin, you should "send" either endl or flush to cout. Thus:

std::cout << std::endl;

OR

std::cout << std::flush;


Regards,

Rich