Reputation: 105
I've never seen anything like this before and I can't figure out what could possibly be causing it. This is HW so you don't have to fix it for me just give me a clue whats going wrong. Here is my code.
void countChars(ifstream& inData, string filename, char x[])
{
for(int i=0; i < 58; i++)
x[i] = 33+i;
cout << x << endl;
}
here is my output
Upvotes: 1
Views: 74
Reputation: 5101
You forgot to null terminate your char[]
.
std::cout.operator<<(char*)
uses \0
to tell where to stop.
This is a duplicate of: this
Upvotes: 4