I have an array of type 'char' with the last symbol '\0'.
#include<iostream>
void main()
{
char a[4];
a[0] = 'r';
a[1] = 'r';
a[2] = 'r';
a[3] = '\0';
for (int i = 0; i < 6; i++)
{
cout << a[i];
}
cout << endl;
}
So, when I try to output more symbols than this array has, It prints random symbols after '\0' symbol.
Output:
rrr ╠╠
My question is: how can I create my array with no symbols after '\0' symbol ?