Store input that hasn't been passed to cin yet

I'm making an IM system, I want both the clients and the server to update and show any messages that have been sent without erasing what has been typed, is there a way that I can store input that would be passed to cin without having to press enter? thanx in advance
Yes there is a way, I'm not sure about with cin. I don't think you need to, nor want to do this for your IM messaging system.

But here is how to capture keystrokes without waiting for enter.

1
2
3
4
5
6
7
8
9
10
11
string line;
char c;
do 
{
   c = _getche(); //echos your key press.
   if(c != 0x0D)
      line+=c;
   //...
   //... Do whatever it is you think you need to do before enter is pressed...
   //...
} while (c != 0x0D);
I'm guessing that 0x0D is the hex form of the escape character? also, why is there an underscore in front of getche()? is there a difference between _getche() and getche()? thnx
There is no difference, they are both deprecated.

At this point if you want to be doing these sort of things (IM chat, games, etc) then you should not use the console as using the console for things like this is harder than using a graphics library for making your own windows.
I probably will eventually add a nice window but I'm to lazy to try and learn how to use the windows API and the window system that comes with the SFML library is only really designed for video games, which granted I could make it work, none the less I'd prefer to not try and use SFML for a window like the one i would need.
Is there a problem with him designing the back end in a console, and just do the front end with some sort of graphics library?
Is there a problem with him designing the back end in a console, and just do the front end with some sort of graphics library?


Nope. We write services that hook up to a client (or not), we have test projects running consoles, it's perfectly acceptable.
Topic archived. No new replies allowed.