cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
how to set fixed length for string ?
how to set fixed length for string ?
May 28, 2013 at 7:21pm UTC
codeback99
(57)
Input
The input consists of one or more packets followed by a line containing only # that signals the end of the input. Each packet is on a line by itself, does not begin or end with a space, and contains from 1 to 255 characters.
it said 1 to 255 characters
i have to use getline(cin,str);
i tried str[255] but some error happen
May 28, 2013 at 8:00pm UTC
MiiNiPaa
(8886)
some error happen
What error. I suppose it "cannot convers char[255] to std::string".
In that case use std::cin.getline(str, 255);
May 29, 2013 at 7:49am UTC
ajh32
(659)
Have you tried std::string instead of char[] ?
Topic archived. No new replies allowed.