how to set fixed length for string ?


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
some error happen
What error. I suppose it "cannot convers char[255] to std::string".

In that case use std::cin.getline(str, 255);
Have you tried std::string instead of char[] ?
Topic archived. No new replies allowed.