i am just wondering how to get input from the arrow keys
i am just wondering how to get input from the arrow keys
ok i made a program that creates a window in dos please help me figure out what is wrong it compiles but when i execute and after i enter my numbers it says that it encounter problems and had to close
Code:#include "stdafx.h" int createwindow(int x,int y); struct window{ int x,y; }test; int main(int argc, char* argv[]) { printf("enter the x dimension\n"); scanf("%d",&test.x); printf("\nenter the y dimension\n"); scanf("%d"); createwindow(test.x,test.y); return 0; } int createwindow(int x,int y){ int help1,help2,help3; for(help1=0;help1==x;help1++){ printf("-"); for(help2=0;help2==y;help2++){ printf("|"); for(help3=0;help3==(x-2);help3++){ printf(" "); printf("|"); } } } return 0; }
i optimized my program but this doesnt work either please smeone tell me what is wrong?
Code:#include "stdafx.h" int createwindow(int x,int y); struct window{ int x,y; }; int main(int argc, char* argv[]) { window test; printf("enter the x dimension\n"); scanf("%d",&test.x); printf("\nenter the y dimension\n"); scanf("%d"); createwindow(test.x,test.y); return 0; } int createwindow(int x,int y){ int help,help1; for(help=0;help1==x;help++){ printf("-"); } for(help=0;help==y;help++){ printf("|"); for(help1=0;help1==(x-2);help1++){ printf(" "); } } for(help=0;help==x;help++){ printf("-"); } return 0; }
ok sorry guys for wasting your time i found the problem but now i have another problem when i enter the numbers it says press enter to contnue i will show my new codeCode:#include "stdafx.h" int createwindow(int x,int y); struct window{ int x,y; }; int main(int argc, char* argv[]) { window test; printf("enter the x dimension\n"); scanf("%d",&test.x); printf("\nenter the y dimension\n"); scanf("%d",&test.y); createwindow(test.x,test.y); return 0; } int createwindow(int x,int y){ int help,help1; for(help=0;help1==x;help++){ printf("-"); } for(help=0;help==y;help++){ printf("|"); for(help1=0;help1==(x-2);help1++){ printf(" "); } } for(help=0;help==x;help++){ printf("-"); } return 0; }
>>i am just wondering how to get input from the arrow keys
http://faq.cprogramming.com/cgi-bin/...&id=1043284392
>>for(help=0;help1==x;help++)
and
>>for(help=0;help==y;help++)
and
>>for(help1=0;help1==(x-2);help1++)
and
>>for(help=0;help==x;help++)
The test condition is wrong. I'd guess you'd want something more like:
>>for(help=0;help < x;help++)
... or maybe something similar?
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Write an interrupt 09h interrupt handler.
For C++ use (...) and for C use (void) in interrupt <somefunc>().
Code:#define DOWN 1 #define UP 0 #define FALSE 0 #define TRUE 1 typedef unsigned char BYTE; BYTE keys[128]; int HandlerInstalled; interrupt *OldHandler=0; void StartKeyboard(void); void EndKeyboard(void); interrupt NewKeyHandler(...) { BYTE ch=inportb(0x60); if (ch<128) { keys[ch]=DOWN lastkey=ch } else { if (ch==170) { keys[lastkey]=UP; lastkey=ch; } else { keys[ch-128]=UP; lastkey=ch-128; } } //Acknowledge EOI outportb(0x20,0x20); } void StartKeyboard(void) { //register our exit function //This will not catch CTRL-C or int 23h //But with handler installed - CTRL-C will do nothing //Upon normal termination of code - EndKeyboard will always be //called atexit(EndKeyboard); //Save old handler OldHandler=getvect(0x09); //Install new one setvect(0x09,NewKeyHandler); HandlerInstalled=TRUE; } void EndKeyboard(void) { if (HandlerInstalled) { setvect(0x09,OldHandler); HandlerInstalled=FALSE; } }
Then to test whether or not a key is down:
if (keys[key_scan_code] dosomething();