Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <ncurses.h>
- void arr_del(void);
- void arr_push(char);
- char arr[100];
- int main()
- {
- initscr();
- int row, col;
- getmaxyx(stdscr, row, col);
- char ch;
- arr[0] = '\0';
- while(1) {
- ch = getch();
- if (ch == KEY_BACKSPACE)
- arr_del();
- else
- arr_push(ch);
- mvprintw(row/2-1, col/2, "%c", arr[strlen(arr)-1]);
- mvprintw(row/2, (col - strlen(arr))/2, "%s", arr);
- mvprintw(row/2+1, col/2, "%d", strlen(arr));
- refresh();
- }
- return 0;
- }
- void arr_del(void) {
- //int len = strlen(arr);
- arr[strlen(arr)-1] = '\0';
- }
- void arr_push(char ch) {
- int len = strlen(arr);
- arr[len] = ch;
- arr[len+1] = '\0';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement