• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

C++ command line help

newbiepcuser

Diamond Member
If anybody can help me, I would appreaciate it.

command line C++

I have character array of 5, and I want to either allow a user to input as many character and discard anything after five bytes, append the 5 with \0 or stop the user the from input more than 4 characters.

ie

char temp [5];

cout <<"please input your your information : "<<"\n";

//user types garble, but i only want 4 characters and null appended;


std:fstream.write(temp,4);


 
Put a loop to read each character instead of a string

while (true)
{
icount++
if (icount > 4)
// reject anything entered after the fourth character
else
// accept characers 1-4
...
}
 
Back
Top