c++ languange tutorial :character arrays
print?#include "stdio.h"
int main()
{
int a[10]={0,1,2,3,4,5,6,7,8,9};
char b[6]={'H','E','L','L','O','\0'};
printf("sizeof INT is: %d\n",sizeof(int));
int i=0;
for(i=0;i<10;i++)
printf("a[%d]=%d, &a[%d]=%d\n",i,a[i],i,&a[i]);
printf("sizeof CHAR is: %d\n",sizeof(char));
for(i=0;i<6;i++)
{
//printf("b[%d]=%d, &b[%d]=%d\n",i,b[i],i,&b[i]);
printf("b[%d]=%c, &b[%d]=%d\n",i,b[i],i,&b[i]);
}
printf("\n");
for(i=0;i<6;i++)
{
printf("b[%d]=%d, &b[%d]=%d\n",i,b[i],i,&b[i]);
//printf("b[%d]=%c, &b[%d]=%d\n",i,b[i],i,&b[i]);
}
return 0;
}
/**
OCS101:~/cpl # gcc testArray.c
OCS101:~/cpl # ./a.out
sizeof INT is: 4
a[0]=0, &a[0]=-1857442672
a[1]=1, &a[1]=-1857442668
a[2]=2, &a[2]=-1857442664
a[3]=3, &a[3]=-1857442660
a[4]=4, &a[4]=-1857442656
a[5]=5, &a[5]=-1857442652
a[6]=6, &a[6]=-1857442648
a[7]=7, &a[7]=-1857442644
a[8]=8, &a[8]=-1857442640
a[9]=9, &a[9]=-1857442636
sizeof CHAR is: 1
b[0]=H, &b[0]=-1857442688
b[1]=E, &b[1]=-1857442687
b[2]=L, &b[2]=-1857442686
b[3]=L, &b[3]=-1857442685
b[4]=O, &b[4]=-1857442684
b[5]=, &b[5]=-1857442683
b[0]=72, &b[0]=-1857442688
b[1]=69, &b[1]=-1857442687
b[2]=76, &b[2]=-1857442686
b[3]=76, &b[3]=-1857442685
b[4]=79, &b[4]=-1857442684
b[5]=0, &b[5]=-1857442683
OCS101:~/cpl # ./a.out
sizeof INT is: 4
a[0]=0, &a[0]=1756439296
a[1]=1, &a[1]=1756439300
a[2]=2, &a[2]=1756439304
a[3]=3, &a[3]=1756439308
a[4]=4, &a[4]=1756439312
a[5]=5, &a[5]=1756439316
a[6]=6, &a[6]=1756439320
a[7]=7, &a[7]=1756439324
a[8]=8, &a[8]=1756439328
a[9]=9, &a[9]=1756439332
sizeof CHAR is: 1
b[0]=H, &b[0]=1756439280
b[1]=E, &b[1]=1756439281
b[2]=L, &b[2]=1756439282
b[3]=L, &b[3]=1756439283
b[4]=O, &b[4]=1756439284
b[5]=, &b[5]=1756439285
b[0]=72, &b[0]=1756439280
b[1]=69, &b[1]=1756439281
b[2]=76, &b[2]=1756439282
b[3]=76, &b[3]=1756439283
b[4]=79, &b[4]=1756439284
b[5]=0, &b[5]=1756439285
OCS101:~/cpl # ./a.out
sizeof INT is: 4
a[0]=0, &a[0]=370342176
a[1]=1, &a[1]=370342180
a[2]=2, &a[2]=370342184
a[3]=3, &a[3]=370342188
a[4]=4, &a[4]=370342192
a[5]=5, &a[5]=370342196
a[6]=6, &a[6]=370342200
a[7]=7, &a[7]=370342204
a[8]=8, &a[8]=370342208
a[9]=9, &a[9]=370342212
sizeof CHAR is: 1
b[0]=H, &b[0]=370342160
b[1]=E, &b[1]=370342161
b[2]=L, &b[2]=370342162
b[3]=L, &b[3]=370342163
b[4]=O, &b[4]=370342164
b[5]=, &b[5]=370342165
b[0]=72, &b[0]=370342160
b[1]=69, &b[1]=370342161
b[2]=76, &b[2]=370342162
b[3]=76, &b[3]=370342163
b[4]=79, &b[4]=370342164
b[5]=0, &b[5]=370342165
*/
#include "stdio.h"
int main()
{
int a[10]={0,1,2,3,4,5,6,7,8,9};
char b[6]={'H','E','L','L','O','\0'};
printf("sizeof INT is: %d\n",sizeof(int));
int i=0;
for(i=0;i<10;i++)
printf("a[%d]=%d, &a[%d]=%d\n",i,a[i],i,&a[i]);
printf("sizeof CHAR is: %d\n",sizeof(char));
for(i=0;i<6;i++)
{
//printf("b[%d]=%d, &b[%d]=%d\n",i,b[i],i,&b[i]);
printf("b[%d]=%c, &b[%d]=%d\n",i,b[i],i,&b[i]);
}
printf("\n");
for(i=0;i<6;i++)
{
printf("b[%d]=%d, &b[%d]=%d\n",i,b[i],i,&b[i]);
//printf("b[%d]=%c, &b[%d]=%d\n",i,b[i],i,&b[i]);
}
return 0;
}
/**
OCS101:~/cpl # gcc testArray.c
OCS101:~/cpl # ./a.out
sizeof INT is: 4
a[0]=0, &a[0]=-1857442672
a[1]=1, &a[1]=-1857442668
a[2]=2, &a[2]=-1857442664
a[3]=3, &a[3]=-1857442660
a[4]=4, &a[4]=-1857442656
a[5]=5, &a[5]=-1857442652
a[6]=6, &a[6]=-1857442648
a[7]=7, &a[7]=-1857442644
a[8]=8, &a[8]=-1857442640
a[9]=9, &a[9]=-1857442636
sizeof CHAR is: 1
b[0]=H, &b[0]=-1857442688
b[1]=E, &b[1]=-1857442687
b[2]=L, &b[2]=-1857442686
b[3]=L, &b[3]=-1857442685
b[4]=O, &b[4]=-1857442684
b[5]=, &b[5]=-1857442683
b[0]=72, &b[0]=-1857442688
b[1]=69, &b[1]=-1857442687
b[2]=76, &b[2]=-1857442686
b[3]=76, &b[3]=-1857442685
b[4]=79, &b[4]=-1857442684
b[5]=0, &b[5]=-1857442683
OCS101:~/cpl # ./a.out
sizeof INT is: 4
a[0]=0, &a[0]=1756439296
a[1]=1, &a[1]=1756439300
a[2]=2, &a[2]=1756439304
a[3]=3, &a[3]=1756439308
a[4]=4, &a[4]=1756439312
a[5]=5, &a[5]=1756439316
a[6]=6, &a[6]=1756439320
a[7]=7, &a[7]=1756439324
a[8]=8, &a[8]=1756439328
a[9]=9, &a[9]=1756439332
sizeof CHAR is: 1
b[0]=H, &b[0]=1756439280
b[1]=E, &b[1]=1756439281
b[2]=L, &b[2]=1756439282
b[3]=L, &b[3]=1756439283
b[4]=O, &b[4]=1756439284
b[5]=, &b[5]=1756439285
b[0]=72, &b[0]=1756439280
b[1]=69, &b[1]=1756439281
b[2]=76, &b[2]=1756439282
b[3]=76, &b[3]=1756439283
b[4]=79, &b[4]=1756439284
b[5]=0, &b[5]=1756439285
OCS101:~/cpl # ./a.out
sizeof INT is: 4
a[0]=0, &a[0]=370342176
a[1]=1, &a[1]=370342180
a[2]=2, &a[2]=370342184
a[3]=3, &a[3]=370342188
a[4]=4, &a[4]=370342192
a[5]=5, &a[5]=370342196
a[6]=6, &a[6]=370342200
a[7]=7, &a[7]=370342204
a[8]=8, &a[8]=370342208
a[9]=9, &a[9]=370342212
sizeof CHAR is: 1
b[0]=H, &b[0]=370342160
b[1]=E, &b[1]=370342161
b[2]=L, &b[2]=370342162
b[3]=L, &b[3]=370342163
b[4]=O, &b[4]=370342164
b[5]=, &b[5]=370342165
b[0]=72, &b[0]=370342160
b[1]=69, &b[1]=370342161
b[2]=76, &b[2]=370342162
b[3]=76, &b[3]=370342163
补充:软件开发 , C++ ,