Stop Microsoft
Miscellaneous => Programming & Networking => Topic started by: Kintaro on 8 November 2002, 15:53
-
I have a question for C/C++
Whats a damn function that can be used like a variable for key input
For example in basic there is the INKEY$ variable which always is the current key being used... Whats the C/C++ equiv?
-
quote:
What's a damn functionthat can be used like a variable for key input
Try this damn function:
_______________________________________
Live Free or Die: Linux
(http://www.otakupc.com/etsig/dolphin.gif)
Their fundamental design flaws are completely concealed by their superficail design flaws.
-
Thank-you ill try that damn function!
-
Oh sorry i ment C++
This didnt work:
-
errr i can try/*havn't tested this though*/
that should do it. ill test it though
[ November 09, 2002: Message edited by: choasforages ]
-
and it does work.
-
Yes but i want it to do other things until a key is pressed in the loop, then it will interupt it.
-
errr, now your making me think. what kind of things and for your previose example
try tacking this on the includes section
-
Still wont work
wheres god/voidmain when you need him
-
hahah, see if this solves your problem, but you still have to hit enter. im working on it
just rember to tell g++
-lpthreads
im looking into unbuffered streams
-
it seems to have given me this
quote:
[X11@X11 X11]$ vi blah.cpp
[X11@X11 X11]$ gcc -o blah blah.cpp
In file included from /usr/include/c++/3.2/backward/iostream.h:31,
from blah.cpp:1:
/usr/include/c++/3.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using
one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
/tmp/ccXRbBiD.o: In function `main':
/tmp/ccXRbBiD.o(.text+0x63): undefined reference to `std::cout'
/tmp/ccXRbBiD.o(.text+0x68): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std: :o perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccXRbBiD.o(.text+0x83): undefined reference to `std::cout'
/tmp/ccXRbBiD.o(.text+0x88): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std: :o perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccXRbBiD.o(.text+0x98): undefined reference to `std::cout'
/tmp/ccXRbBiD.o(.text+0x9d): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std: :o perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccXRbBiD.o(.text+0xaf): undefined reference to `std::cout'
/tmp/ccXRbBiD.o(.text+0xb4): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std: :o perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccXRbBiD.o: In function `__static_initialization_and_destruction_0(int, int)':
/tmp/ccXRbBiD.o(.text+0xe0): undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccXRbBiD.o: In function `__tcf_0':
/tmp/ccXRbBiD.o(.text+0x10f): undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/ccXRbBiD.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
[ November 09, 2002: Message edited by: Calum & his insidious little spies ]
-
type g++ instead of gcc
it goes like this
g++ -o blah blah.cpp -lpthreads
[ November 09, 2002: Message edited by: choasforages ]
-
hehehe, got it to work but its probably not that portable, and i used a little bit of help with the usage of ioctl's. if you were to use only ncurses, it would probably end up being better ill try it later but here is that exakmple that works.
compile it with
g++ -o blah blah.cpp -lpthreads
-
Its still not working :(
Heres the error output:
quote:
[X11@X11 X11]$ g++ -o blah blah.cpp -lpthreads
In file included from /usr/include/c++/3.2/backward/iostream.h:31,
from blah.cpp:1:
/usr/include/c++/3.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using
one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
/usr/bin/ld: cannot find -lpthreads
collect2: ld returned 1 exit status
[ November 10, 2002: Message edited by: Ex Eleven / b0b 2.1 ]
-
ooops, i feel stupid its
g++ -o blah blah.cpp -lpthread
extra s on the -lpthread was fooking it up
-
Cool it works, but is there a more simple way?
I dont exactly need a thread just a variable that tells me the value of the key being pressed for example:
Do you get what i mean?
-
Do you get what i mean?[/qb]<hr></blockquote>
How about this
My code isn't the neatest or the greatest and you could probably remove the keypress() function but otherwise it might work. I havent tested it.
[ November 13, 2002: Message edited by: smokey mcp0t / b0b ]
[ November 13, 2002: Message edited by: smokey mcp0t / b0b ]