This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
bug?
- From: Alexey Sokolov <sokolhacker at mail dot ru>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 26 Aug 2005 02:32:35 +0000
- Subject: bug?
- Reply-to: sokolhacker at mail dot ru
Hallo!
/**************************/
//example file "example.cpp"
//begin
#include <iostream.h>
main()
{
char name[1]; //1 byte(!)
name[0]='1';
name[1]='2';
name[2]='3';
name[3]='4';
name[4]='\0';
cout << name << "\n";
}
//end
/**************************/
$g++ example.cpp
$./a.out
1234
1,2,3,4 and '\0' = 5 byte!
5 byte != 1 byte (char name[1];)!
But why? Forgive for English, I am simple Russian =)
--
#gcc --version
gcc (GCC) 3.4.2 [FreeBSD] 20040728