How to prevent user typing more than 50 alphabet in terminal

  c++, char, cygwin, string, vector

I hope you understand my question clear.
I know how to validate and everything using if statements like if the maxWords exceeded then print a message. However, this is not what I’m looking for.

I need help like when I run my script in terminal, a user has a fixed number of characters to enter, if the user reached the max, then the user can’t write more than the max or it will stop to the last character and user can enter but only can delet from it and change.

I’m using Cygwin and c++

Source: Windows Questions C++