This article has been dead for over three months
You
void ShellBufString ( char *str, const int SizeOfArray ) {
int i;
char ch = 'a';/*dummy character in ch */
for ( i = 0; i < SizeOfArray; ) {
ch = getch();
if ( ch == 13 ) {
break;
}
else if ( ch == 8 ){
if( i != 0 ) { /*this is for avoiding the ENTER instructions getting deleted */
printf( "\b" ); /*printing backspace to move cursor 1 pos back*/
printf( "%c", 32 );/*making the char invisible which is already on console*/
printf( "\b" ); /*printing backspace to move cursor 1 pos back*/
i--;
str[ i ] = '\0';
}
else {
continue;
}
}
else if ( ch == 0 || ch == -32 || ch == 27 || ch == 9 ) {
/* f1 to f12 Insert home etc., arrow keys, esc, tab */
ch = getch ();
continue;
}
else if ( i == SizeOfArray - 1 ) {
printf( "\b" ); /*printing backspace to move cursor 1 pos back*/
printf( "%c", 32 );/*making the char invisible which is already on console*/
printf( "\b" ); /*printing backspace to move cursor 1 pos back*/
i--;
}
else {
putchar( ch );/* char will be printed instead of the character */
str[ i ] = ch;
i++;
}
}
str[ i ] = '\0'; /* Add null terminator */
printf ( "\n" ); /* Simulate the user pressing enter */
}