Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <string.h>
- void input(const unsigned n, char* const to, char* const using)
- {
- int _tmp;
- unsigned i = 0;
- if (!using)
- return;
- while (i < n)
- {
- _tmp = getch();
- if (_tmp == ENTER)
- {
- to[i++] = '\0';
- break;
- }
- else if (_tmp == BACKSPACE && i > 0)
- {
- printf("\b \b");
- i--;
- }
- else if (_tmp == ESCAPE)
- {
- exit(0);
- }
- else if (_tmp == 0)
- {
- continue;
- }
- else if (strchr(using, _tmp))
- {
- to[i++] = _tmp;
- putchar(_tmp);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement