- 论坛徽章:
- 0
|
#include <string.h>
#include <iostream.h>
//#include <cstddef.h>
using namespace std;
int main()
{
size_t ia;
ia = sizeof( ia ); // ok
ia = sizeof ia; // ok
// ia = sizeof int;
ia = sizeof( int ); // ok
int *pi = new int[ 12 ];
cout << "pi: " << sizeof( pi )
<< " *pi: " << sizeof( *pi )
<< endl;
string st1( "foobar" );
string st2( "a mighty oak" );
string *ps = &st1;
cout << "st1: " << sizeof( st1 )
<< " st2: " << sizeof( st2 )
<< " st2: " << sizeof( st2 )
<< " ps: " << sizeof( ps )
<< " *ps: " << sizeof( *ps )
<< endl;
cout << "short :\t" << sizeof(short) << endl;
cout << "short* :\t" << sizeof(short*) << endl;
cout << "short& :\t" << sizeof(short&) << endl;
cout << "short[3] :\t" << sizeof(short[3]) << endl;
}
$ xlC_r -o sizeof_test sizeof_test.C
"sizeof_test.C", line 4.9: 1540-320: (S) Syntax error - found "using namespace"
: "using" is not a type name.
"sizeof_test.C", line 19.8: 1540-320: (S) Syntax error - found "string st1" : "s
tring" is not a type name.
"sizeof_test.C", line 20.8: 1540-320: (S) Syntax error - found "string st2" : "s
tring" is not a type name.
"sizeof_test.C", line 21.15: 1540-013: (S) Identifier "st1" is undefined.
"sizeof_test.C", line 21.1: 1540-013: (S) Identifier "string" is undefined.
"sizeof_test.C", line 21.9: 1540-013: (S) Identifier "ps" is undefined.
"sizeof_test.C", line 23.24: 1540-013: (S) Identifier "st2" is undefined. |
|