I have wrote this:
Code:
#include <stdio.h>
#include <conio.h>
void main()
{
/* variables define here */
char lgn, beep = 0x07, ctrl_char;
/* Start of program */
printf("Welcome to Students DataBase\n");
/* Main page */
main:
printf("you want to login as Teacher or Student (T/S):");
lgn_check:
lgn = getche();
if (lgn == 0x08){
printf("%c:", beep);
goto lgn_check;
}
else if (lgn == 0x0D || lgn == 0x03){
printf("%c", beep);
goto lgn_check;
}
ctrl_char = getch();
ctrl_char_check:
if (ctrl_char == 0x08){
printf("\b");
lgn = getche();
ctrl_char = getch();
if (ctrl_char == 0x08)
goto ctrl_char_check;
}
switch (lgn){
case 'T':
case 't':
printf("\nyou loged in as Teacher.\nPlease enter your password:");
goto teacher;
break;
case 'S':
case 's':
printf("\nyou loged in as Student.\n");
goto student;
break;
default:
printf("\n%cError: unknown command\n", beep);
goto main;
}
// End of main loop
teacher:
/* teacher commands */
// End of teacher loop
student:
/* student commands */
// End of student loop
}
when I press "enter" key the cursor go to start of line. but I want it stay where it is.
thanks to all