nick3 said:
I want to fill an array with 20 blanks (" "), so I did a for loop
for(int i = 0; i <= 20; i++)
item[i] = (char)" ";
If item is a string, you're doing it wrong. A space character is
' ' (single quotes). You seem to be assigning the address of a string literal.
Why the cast if you are otherwise doing it correctly (I find that many casts, especially by folks new to the language, are used to erroneously shut the compiler up when it's trying to tell you to do the right thing).
Also, your loop has 21 iterations. If your array has 20 elements, you're overrunning the array.
And C-style strings end in a null character,
'\0'.
Bear in mind that some of what I mentioned might not apply if item is a
std::string. Often the most important bit of relevant information in a post, the data type, seems to be frequently omitted by forum posters. I've never figured that out.