In many programs to do commands you hit cntrl-a or somthing to save in consle mod how do you do this i have no clue at all im thinking its done with getch() some how but im not sure
In many programs to do commands you hit cntrl-a or somthing to save in consle mod how do you do this i have no clue at all im thinking its done with getch() some how but im not sure
Control-keypress "commands" are a way of sending a signal to a running process. A signal is a type of inter-process comunication that alerts the program to an exceptional condition and tells it to do something (usually quit now, save and quit, or set some flag). I'm not sure how to handle signals in DOS, but if you query a decent search engine for trapping signals in dos or the like, you should be able to find something.
starX
www.axisoftime.com
---------------
starX
www.axisoftime.com
Yes it can be done with getch().
Getch() return's you ASCII value of character, if you press normal key. When you press smthinng like Ctrl+A firstly getch() returns zero. So you must call getch() once more to get special scancode number. If you want to handle keys like ctrl+a or cursor keys this code tels you what scancode appropiate to your ctrl+smthing:
#include <conio.h>
#include <stdio.h>
main()
{
char c;
printf("Press something!\n");
if((c=getch())==0)
{
c=getch(); //getch() must be call onesmore to
//get scancode
printf("You press smthing special\n);
printf("Scancode:%d",c);
}
else
{
printf("You press normal key\n");
printf("ASCII value:%d",c);
}
return(0);
}