strange error

ok so this is my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <conio.h>
#include <cstdlib>
#include <cstdio>
#include <windows.h>
#include <string>

using namespace std;

using namespace std;

int main()
{

    const char thisisthetextthatshouldcomeup [] = {'t','h','i','s','i','s','t','h','e','t','e','x','t','t','h','a','t','s','h','o','u','l','d','c','o','m','e','u','p'};
    cout << thisisthetextthatshouldcomeup;
    return 0;
}

but for some strange reason, even though I didn't put it in the code, after the text it displays ☺ ". Why is this and how do I fix it?
You didn't put '\0' as the last character in your character array.

The smiley face must have been the next byte value in memory after 'p' before cout found a '\0' to stop printing the char array.
Last edited on
Thanks a lot.
Topic archived. No new replies allowed.