Hi anybody
do you know how to limit string that we input in the program ?
LIKE THIS:
Input Name: <-we can input only 5 characters

Do you want the user to be able to type 5 characters and no more, or is it a case where you can just take the first 5 off of what they type?

You need to define what exactly you mean by limit. For example what should happen in the sixth character? Should the program just go with the first five character or should the program output an error message if more that 5 character is entered or should the program enable the user to input only 5 letters and any extra characters entered is ignored and not read as input? Not all of these choices can be done with pure C++.

i want user input only 5 characters

See WaltP's suggestion in this thread: http://www.daniweb.com/forums/post742441.html#post742441

Try to code it, post what you have, and someone ought to be able to refine it.

As firstPerson said, this can be accomplished through some libraries, but the solutions may not be portable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.