KeyPressed function?

K

Karl Ebener

Hi!

A newbie question: How can I check, whether a key has been pressed and
take that input to perform some action? I don't want to wait for that
input (=> no Enter needed) and the input should not be displayed.

Tnx a lot

Karl
 
K

Karl Heinz Buchegger

Karl said:
Hi!

A newbie question: How can I check, whether a key has been pressed and
take that input to perform some action? I don't want to wait for that
input (=> no Enter needed) and the input should not be displayed.

There is nothing in standard C++ to help you.
Mostly because standard C++ is not aware of a keyboard.
All input or output is generalized to a stream.

But that doesn't mean that it can't be done on your
specific system. All it means is that there is no
general solution. You need system specific functionality
to do that.
 
K

Karl Ebener

Hi!
There is nothing in standard C++ to help you.
Mostly because standard C++ is not aware of a keyboard.
All input or output is generalized to a stream.

But that doesn't mean that it can't be done on your
specific system. All it means is that there is no
general solution. You need system specific functionality
to do that.

Could you give me a hint for Linux systems? I looked but didn't find
anything....

Another question: Is there a way to make a function return a list?
e.g.
int[] abc() { //*returning list*}

Tnx
Karl
 
C

chris

Karl said:
Hi!
There is nothing in standard C++ to help you.
Mostly because standard C++ is not aware of a keyboard.
All input or output is generalized to a stream.

But that doesn't mean that it can't be done on your
specific system. All it means is that there is no
general solution. You need system specific functionality
to do that.

Could you give me a hint for Linux systems? I looked but didn't find
anything....

Another question: Is there a way to make a function return a list?
e.g.
int[] abc() { //*returning list*}
You can return arrays, but doing so requires you to use new[] and
delete[] and deal with the memory management yourself.

A much better idea would be to use "vector" or "list", which are classes
provided by c++ which are much easier to deal with than plain arrays.
Look them up in any good (or even most bad) C++ books :)

Chris
 
K

Karl Heinz Buchegger

Karl said:
Hi!

Could you give me a hint for Linux systems? I looked but didn't find
anything....

Sorry. I donÄt know about Linux. You should ask in a newsgroup dedicated
to Linux programming.
Another question: Is there a way to make a function return a list?
e.g.
int[] abc() { //*returning list*}

int[] is not a list.
It is the notation for an array with unknown dimensions. But
beware, in this case things are not what they seem to be. The
above is in reality a way to avoid pointer notation, nothing
more. And it cannot be used as return type.

As for a list:

#include <list>

std::list<int> foo()
{
list<int> MyList;

MyList.push_back( 5 );
MyList.push_back( 7 );

return MyList;
}
 
D

Default User

Karl said:
Could you give me a hint for Linux systems? I looked but didn't find
anything....

Most likely something in the curses library. An excellent place to
start is comp.unix.programmer.




Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top