Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //: Link with -lncurses
- #include <string>
- #include <sstream>
- extern "C" {
- #include <ncurses.h>
- }
- int read_value(void) {
- std::string buffer;
- do {
- buffer.push_back(getch());
- } while (buffer.back() != ' ' && buffer.back() != '\n');
- int value;
- std::stringstream(buffer) >> value;
- return value;
- }
- void interact(void) {
- printw("Input your height:\n");
- refresh();
- int feets = read_value();
- printw("feet(s) and ");
- refresh();
- int inches = read_value();
- printw("inche(s).\nAnd your weight is ");
- refresh();
- int pounds = read_value();
- printw("pound(s).");
- }
- void pause(void) {
- printw("\n\nPress any key...");
- refresh();
- getch();
- }
- int main()
- {
- initscr();
- interact();
- pause();
- endwin();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement