28 lines
615 B
C++
28 lines
615 B
C++
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
char strs[2][1024];
|
|
|
|
size_t sizeof_by_pchar(char *str)
|
|
{
|
|
return sizeof(str);
|
|
}
|
|
|
|
size_t sizeof_by_char_arr(char str[])
|
|
{
|
|
return sizeof(str);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
cout << sizeof(strs) << endl;
|
|
cout << sizeof(strs[0]) << endl;
|
|
cout << sizeof(strs[0][0]) << endl;
|
|
for (size_t i = 0; i < sizeof(strs) / sizeof(strs[0]); i++)
|
|
{
|
|
cout << "sizeof array: " << sizeof(strs[i]) << endl;
|
|
cout << "param by char pointer: " << sizeof_by_pchar(strs[i]) << endl;
|
|
cout << "param by char array: " << sizeof_by_char_arr(strs[i]) << endl;
|
|
}
|
|
} |