先看一下代码:
#include <iostream>
using namespace std;
int main() {
char a[100];
cin >> a;
cout << strlen(a) << endl;
cout << sizeof(a);
cin >> a;
return 0;
}
看一下运行:
接下来看一下动态分配数组:
//一维数组动态申请,c数组大小为: n
int *c = new int[n];
//二维数组动态申请,b数组大小为: n*p
int **b = new int*[n];
for (int i = 0; i<n; i++)
b[i] = new int[p];
//三维数组动态申请, a数组大小为: m*n*p:
int ***a = new int **[m];
for (i = 0; i<m; i++)
{
a[i] = new int *[n];
for (j = 0; j<n; j++){
a[i][j] = new int[p];
}