八卦走圈八个动作:char a[]="It is me"是不是说a中只能存放8个字符啊?
来源:百度文库 编辑:查人人中国名人网 时间:2024/05/21 22:48:09
我的理解
char a[]="It is me";
等价于
char a[9]="It is me";
其中a[8]='\0';
数组中只能存放8个ASCII码字符
而a只是一个指针,指向a[0]
经验证,楼上的cout<<sizeof a;为9~~^Q^
#include <iostream>
using namespace std;
void main()
{
char a[]="it is me";//这里其实定义了a[9],因为字符串最后会有一个'\0'结尾~
cout<<sizeof a;//=9
}
char a[]="It is me"
这样就隐式的定义了a[8],
a只有8个字符,不信可以用 cout<<sizeof a看看就明白了.
char a[]="it is me";//这里其实定义了a[9],因为字符串最后会有一个'\0'结尾,但也不表示只能存放8个字符,size是随你自己定义大小的,比如int size=19;看你需要多大
不是
只是 a 初始化时有 8 个字符
不是的
看你初始化时有几个字符了
还要加上个'/0'空字符
char a[]="It is me"是不是说a中只能存放8个字符啊?
char a[10]="";是什么意思?
c++ 求助,char>="a"错误?
英语题 Where is "A"? 1It's 2It is'nt
it is a truth
is it a story?
Why is it called a "building" when it's already built?
main() {char *s1 = "abcdeg"; char *s2="a"; s1++; s2++; printf ("%d\n",strcmp(s1,s2));}
It is your turn=( ) a:It is your line b:It is your row c:You are next d:It is your chance
it is not a translation