Author Topic: C Q  (Read 1824 times)

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
C Q
« 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?

jtpenrod

  • VIP
  • Member
  • ***
  • Posts: 675
  • Kudos: 105
C Q
« Reply #1 on: 9 November 2002, 01:31 »
quote:
What's a damn functionthat can be used like a variable for key input
Try this damn function:
Code: [Select]
_______________________________________
Live Free or Die: Linux

Their fundamental design flaws are completely concealed by their superficail design flaws.
Live Free or Die: Linux
If software can be free, why can't dolphins?

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
C Q
« Reply #2 on: 9 November 2002, 14:54 »
Thank-you ill try that damn function!

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
C Q
« Reply #3 on: 9 November 2002, 15:19 »
Oh sorry i ment C++

This didnt work:
Code: [Select]

choasforages

  • VIP
  • Member
  • ***
  • Posts: 1,729
  • Kudos: 7
    • http://it died
C Q
« Reply #4 on: 9 November 2002, 17:04 »
errr i can try/*havn't tested this though*/


Code: [Select]

that should do it. ill test it though

[ November 09, 2002: Message edited by: choasforages ]

x86: a hack on a hack of a hackway
alpha, hewlett packed it A-way
ppc: the fruity way
mips: the graphical way
sparc: the sunny way
4:20.....forget the DMCA for a while!!!

choasforages

  • VIP
  • Member
  • ***
  • Posts: 1,729
  • Kudos: 7
    • http://it died
C Q
« Reply #5 on: 9 November 2002, 17:10 »
and it does work.
x86: a hack on a hack of a hackway
alpha, hewlett packed it A-way
ppc: the fruity way
mips: the graphical way
sparc: the sunny way
4:20.....forget the DMCA for a while!!!

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
C Q
« Reply #6 on: 9 November 2002, 17:22 »
Yes but i want it to do other things until a key is pressed in the loop, then it will interupt it.

choasforages

  • VIP
  • Member
  • ***
  • Posts: 1,729
  • Kudos: 7
    • http://it died
C Q
« Reply #7 on: 9 November 2002, 17:34 »
errr, now your making me think. what kind of things and for your previose example
try tacking this on the includes section

Code: [Select]
x86: a hack on a hack of a hackway
alpha, hewlett packed it A-way
ppc: the fruity way
mips: the graphical way
sparc: the sunny way
4:20.....forget the DMCA for a while!!!

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
C Q
« Reply #8 on: 9 November 2002, 18:14 »
Still wont work

wheres god/voidmain when you need him

choasforages

  • VIP
  • Member
  • ***
  • Posts: 1,729
  • Kudos: 7
    • http://it died
C Q
« Reply #9 on: 9 November 2002, 18:44 »
hahah, see if this solves your problem, but you still have to hit enter. im working on it

Code: [Select]

just rember to tell g++
-lpthreads

im looking into unbuffered streams
x86: a hack on a hack of a hackway
alpha, hewlett packed it A-way
ppc: the fruity way
mips: the graphical way
sparc: the sunny way
4:20.....forget the DMCA for a while!!!

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
C Q
« Reply #10 on: 9 November 2002, 19:01 »
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 ]


choasforages

  • VIP
  • Member
  • ***
  • Posts: 1,729
  • Kudos: 7
    • http://it died
C Q
« Reply #11 on: 9 November 2002, 19:16 »
type g++ instead of gcc
it goes like this

g++ -o  blah blah.cpp -lpthreads

[ November 09, 2002: Message edited by: choasforages ]

x86: a hack on a hack of a hackway
alpha, hewlett packed it A-way
ppc: the fruity way
mips: the graphical way
sparc: the sunny way
4:20.....forget the DMCA for a while!!!

choasforages

  • VIP
  • Member
  • ***
  • Posts: 1,729
  • Kudos: 7
    • http://it died
C Q
« Reply #12 on: 9 November 2002, 22:00 »
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

Code: [Select]
x86: a hack on a hack of a hackway
alpha, hewlett packed it A-way
ppc: the fruity way
mips: the graphical way
sparc: the sunny way
4:20.....forget the DMCA for a while!!!

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
C Q
« Reply #13 on: 10 November 2002, 21:36 »
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 ]


choasforages

  • VIP
  • Member
  • ***
  • Posts: 1,729
  • Kudos: 7
    • http://it died
C Q
« Reply #14 on: 10 November 2002, 20:37 »
ooops, i feel stupid its

g++ -o blah blah.cpp -lpthread

extra s on the -lpthread was fooking it up
x86: a hack on a hack of a hackway
alpha, hewlett packed it A-way
ppc: the fruity way
mips: the graphical way
sparc: the sunny way
4:20.....forget the DMCA for a while!!!