Click here to Skip to main content
15,892,927 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
General(ATL/COM/MFC/C++) Q about IE programming Pin
dojin7915-Jul-05 0:51
dojin7915-Jul-05 0:51 
GeneralRe: (ATL/COM/MFC/C++) Q about IE programming Pin
Douglas Troy15-Jul-05 5:33
Douglas Troy15-Jul-05 5:33 
GeneralRe: (ATL/COM/MFC/C++) Q about IE programming Pin
Member 212103815-Jul-05 20:23
Member 212103815-Jul-05 20:23 
Questionwhat's the right way to do this? Pin
HeartFriend14-Jul-05 22:31
HeartFriend14-Jul-05 22:31 
AnswerRe: what's the right way to do this? Pin
Douglas Troy15-Jul-05 5:40
Douglas Troy15-Jul-05 5:40 
GeneralRe: what's the right way to do this? Pin
Anonymous15-Jul-05 6:05
Anonymous15-Jul-05 6:05 
GeneralRe: what's the right way to do this? Pin
Douglas Troy15-Jul-05 6:14
Douglas Troy15-Jul-05 6:14 
Generalstd::cin and unbuffering (noncanonical input) Pin
Harold Bamford14-Jul-05 8:08
Harold Bamford14-Jul-05 8:08 
Greetings,

First, I apologize for what must be in a FAQ somewhere that I haven't located. I have tried.

Here is the basic question (details below): How do I turn off canonical input processing on an arbritrary istream? Failing that, how do I do it with just cin using VC++ 7.1?

The gory details:

I am writing a function that is part of a larger project so I don't have a lot of control over the style of its parameters. It gets an istream and ostream pointer. With the istream pointer I have to read a character at a time as this is for an interactive application; I need to react to each character as it is entered, not after the entire line has been entered. Like an editor.

But if the istream is std::cin, then I have canonical line processing (no extra charge!) where the characters are echoed to the user, ^H (backspace) is interpreted, and nothing is available to the calling program until a newline has been entered.

If I compile under GCC 3.4.4, I can (with vast pain) determine that the istream is associated with file descriptor 0 (STDIN_FILENO) and use tcgetattr/tcsetattr to turn off the canonical processing.

But these functions (tcgetattr/tcsetattr) do not appear to be available in VC++ 7.1

I have looked for days for a general way to deal with this problem and either it is so obvious that nobody mentions it or I have completely missed it. Even the GCC documentation doesn't give a solution for itself (though I found one on the net). The VC++ documentation casually mentions that istream buffering can be turned off, but doesn't say how. Perhaps they were not referring to canonical processing but something else...

I have tried some of the obvious stuff already:

// Forcing cin to not do line-buffering and echoing
#include <iosfwd>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
	char inChar;

#if 0
	// compiles but input is still line-buffered
	cin.rdbuf()->pubsetbuf(0,0);
#endif

#if 0
	// doesn't compile under cygwin g++ 3.4.4 or VC++ 7.1
	// It was mentioned somewhere on the net so I had to try...
	cin.setbuf(0,0);
#endif

#if 0
	// According to MS, cin is really an ostream (!), so...
	// compiles but input is still line-buffered (wasn't really expecting much)
	cin >> unitbuf;
#endif

#if 0
	// compiles but input is still line-buffered (wasn't really expecting much)
	cin.setf(ios::unitbuf);
#endif

	while(cin)
	{
		cin.get(inChar);
		if(inChar == '\004') break;
		cout << "\nRead in '" << inChar << "'\n" << flush;
	}
	return(0);
}

GeneralVector class is missing 'rerase' Pin
ICantChangeMyAcct13-Jul-05 9:18
ICantChangeMyAcct13-Jul-05 9:18 
GeneralRe: Vector class is missing 'rerase' Pin
Nish Nishant13-Jul-05 9:48
sitebuilderNish Nishant13-Jul-05 9:48 
GeneralRe: Vector class is missing 'rerase' Pin
Roland Pibinger13-Jul-05 12:43
Roland Pibinger13-Jul-05 12:43 
GeneralRe: Vector class is missing 'rerase' Pin
Nemanja Trifunovic14-Jul-05 2:19
Nemanja Trifunovic14-Jul-05 2:19 
GeneralRe: Vector class is missing 'rerase' Pin
Rob Caldecott14-Jul-05 5:25
Rob Caldecott14-Jul-05 5:25 
GeneralBoost Pin
Rob Caldecott11-Jul-05 21:14
Rob Caldecott11-Jul-05 21:14 
GeneralRe: Boost Pin
Nemanja Trifunovic12-Jul-05 3:17
Nemanja Trifunovic12-Jul-05 3:17 
GeneralRe: Boost Pin
guypremont12-Jul-05 3:31
guypremont12-Jul-05 3:31 
GeneralRe: Boost Pin
Stuart Dootson12-Jul-05 8:30
professionalStuart Dootson12-Jul-05 8:30 
GeneralRe: Boost Pin
Rob Caldecott12-Jul-05 11:02
Rob Caldecott12-Jul-05 11:02 
GeneralRe: Boost Pin
CP Visitor12-Jul-05 22:41
CP Visitor12-Jul-05 22:41 
GeneralRe: Boost Pin
Rob Caldecott12-Jul-05 22:51
Rob Caldecott12-Jul-05 22:51 
GeneralRe: Boost Pin
CP Visitor13-Jul-05 6:28
CP Visitor13-Jul-05 6:28 
GeneralRe: Boost Pin
Rob Caldecott13-Jul-05 7:28
Rob Caldecott13-Jul-05 7:28 
GeneralRe: Boost Pin
Joaquín M López Muñoz12-Jul-05 11:27
Joaquín M López Muñoz12-Jul-05 11:27 
GeneralRe: Boost Pin
Nemanja Trifunovic12-Jul-05 12:49
Nemanja Trifunovic12-Jul-05 12:49 
GeneralRe: Boost Pin
Nish Nishant13-Jul-05 19:46
sitebuilderNish Nishant13-Jul-05 19:46 

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.