Qbasicnews.com

Full Version: um more C err welll...kinda like I need umm some help mb?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
well umm I wanna make my own comand in C a comand smilary to the inkey$ in QB and BASIC and the thing is I don´t know how to listen to the keyboard buffert with my while loop so um how do I do it? ( I wanna just it for keyboard poling) and don´t give me RTFM cuz I don´t got any FM about this so if you couldn´t mb tell me how to do here...(if anyone wriths RTFM I´ll execute him/her)
cant anyone help me with this???
Well, several ways.

To wait for a key to be pressed:

Code:
#include <conio.h>
...
main(){
char a;
...
...
a = getch();
}

Keypressed bucle (kinda inkey$)

Code:
#include <conio.h>
#include <stdlib.h>
...
main(){
char a;
...
while(1)   // Infinite loop or whatever
{
   if(keypressed())
   {
      a = getch();
      ... // do things with a
   }
}

These are from borland. The functions may not be the same in your compiler, but they must look a lot like these. Look for them in the help file, and if you don't find them, look for similar names.
k but I wanna make my own funktion doing this not someone elses...
lemme tell you this right now, this whole "anti-lib" policy will not work in c or c++. do not reinvent the wheel, it is time wasted to come up with what nate gave you. that is what libraries are for, to take mundane, routine functions and provide them to you so you dont have to reprogram everything. the function is there for you, use it instead of asking for a routine and then rejecting it because you want it to be your own.
Don't get me wrong, but aren't those libs the standard c libs. Not using stdlib/conio functions in c is like not using MID$ or STR$ in qbasic.
DONT WANT TO USE SOMEONE ELSE'S CODE???
IN C?
TALKING ABOUT STANDARD LIBRARIES?

Oh man, you're crazy...
In that case, you'll be coding in inline assembly...
Do you use printf? It was writen by "someone else's"...

Even qbasic's PRINT and STR$ functions are writen by "someone else's".

And if I told you how to code those keyboard functions in (I don't know what kind of code you want, if not standard functions) say inline assembly you'd be also using "someone else's" code... You'd be using mine!

Does anything make sense? I will never understand those wheel reinventors. If people did everything from scratch we would be still in the 70's talking about techonollogy.
Well, you could lock your own keyboard routine onto the keyboard interrupt, provides absolutely beatiful keyboard access, but its a little tricky to do....

And if i showed it to you it wouldnt be your code now would it? So i guess you cant use it.... Wink

Hehhe, well if anyone here wants the code for that(works under bc)
i can post it here, youll probably want ot modify it a bit...


Or just pick up allegro 1.1 for bc, that probably the best.
I have code for that.

Takes a bunch of hexadecimal keys and converts them to names... or somehtining.

Old "PC Game Programming" book written for C. Reread it several times, still doesn't make sense, mostly.
Quote:Old "PC Game Programming" book written for C. Reread it several times, still doesn't make sense, mostly.
Thats were i got it from, dont know if its the same book, mines game programming in 21 days by andre lamothe.

Good book, but its really outdated now.