char - C++ Limit The Number of Characters Entered -
for program, have function gets users input. made code far, how how can make when i'm typing , if go on text limit, delete previous character , not allow me type anymore unless backspace characters.
#include <iostream> #include <iomanip> using namespace std; int main() { cout << "please enter name: "; char word[10]; cin >> setw(5) >> word; cout << endl; cout << "your name is: " << word << endl; system("pause"); return 0; }
one way use library such gnu readline library. library takes care of details involved in reading lines of text user, line editing , features such maximum length.
Comments
Post a Comment