strlen 与 sizeof
#include<stdio.h>
#include<string.h>
#include<string>
#include<iostream>
using namespace std;
int main()
{
int a[] = {1,2,3,4,5};
int* b = a;
char c[] = {'a','c','c'};
char* d = c;
char e[] = "abcd";
char* f = "abcd";
//string g = "abcd";
//cout<<g.length()<<endl;
//cout<<g<<endl;///C++可以直接输出string的字符串
//printf("%d \n",strlen(f));///4
//printf("%d \n",strlen(e)); ///4
//printf("%d \n",sizeof(a)); ///20
//printf("%d \n",sizeof(a[0]));///4
//printf("%d \n",sizeof(b));///4
//printf("%d \n",sizeof(b[0]));///4
//printf("%d \n",sizeof(c));///3
//printf("%d \n",sizeof(c[0]));///1
//printf("%d \n",sizeof(d));///4
//printf("%d \n",sizeof(d[0]));///1
//printf("%d \n",sizeof(e));///5
//printf("%d \n",sizeof(e[0]));///1
//printf("%d \n",sizeof(f));///4
//printf("%d \n",sizeof(f[0]));///1
///printf("%d \n",sizeof(g));///32
///printf("%d \n",sizeof(g[0]));//1
//printf("%s",e);///e 和 f都可输出,看来是找到最后一个\0来结束输出的
}
posted on 2014-05-16 10:13 berkeleysong 阅读(124) 评论(0) 编辑 收藏 举报