Creating a simple text editor in C++ -
i'm in cs162 class , assignment week create very, simple text editor prompts user input paragraph, type # when finished, , program make simple edits such capitalizing beginning-of-the-sentence words , changing common errors such "teh" "the." now, have trouble getting started these things; know how i'm going correct errors (have program search misspellings , replace words correct spelling/using .upper change upper case), can't started on having user input paragraph , end #. use loop allows user continue typing until type #? like? sorry if seems excessively basic; have trouble getting started programs, since beginner. thank you.
use conio.h
you can use functions like:
getch() - reads character console without buffer or echo
kbhit() determines if keyboard key pressed.
to you're looking for.
edit: user falcom momot, linux systems:
#include <unistd.h> #include <termios.h> char getch() { char buf = 0; struct termios old = {0}; if (tcgetattr(0, &old) < 0) perror("tcsetattr()"); old.c_lflag &= ~icanon; old.c_lflag &= ~echo; old.c_cc[vmin] = 1; old.c_cc[vtime] = 0; if (tcsetattr(0, tcsanow, &old) < 0) perror("tcsetattr icanon"); if (read(0, &buf, 1) < 0) perror ("read()"); old.c_lflag |= icanon; old.c_lflag |= echo; if (tcsetattr(0, tcsadrain, &old) < 0) perror ("tcsetattr ~icanon"); return (buf);
}
Comments
Post a Comment