//GCC编译方式:C:\MinGW\project>gcc-std=c99main.c//编码环境GBK#include<stdio.h>intmain(){intarray[3][4]={{0,1,2,3},{4,5,6,7},{8,9,10,11}};//遍历二维数组,并打印for(inti=0;i<3;i++){for(intj=0;j<4;j++){printf("array[%d][%d]=%d\n",i,j,array[i][j]);}}/*输出:array[0][0]=0array[0][1]=1array[0][2]=2array[0][3]=3array[1][0]=4array[1][1]=5array[1][2]=6array[1][3]=7array[2][0]=8array[2][1]=9array[2][2]=10array[2][3]=11*///字符串的初始化//charstr[100];//定义一个字符串//charstr[100]={'h','e','l','l','o'};//定义一个字符串,并初始化charstr[100]="hello";//多种初始化str[0]='H';str[1]='e';str[2]='\0';//遇到\0,字符串就结束了str[3]='l';str[4]='o';printf("%s\n",str);//字符串就是以\0结尾的数组//输出Heprintf("str=%d\n",sizeof(str));//输出str=100//打印字符数组大小charstr1[]="Hello";printf("str1=%d\n",sizeof(str1));//输出str1=6//固定字符数组大小,研究字符串初始化后是什么东西charstr2[10]="Hello";printf("str2=%d\n",sizeof(str2));//输出str2=10printf("str2[4]char=>%cHEX=>%x\n",str[4],str[4]);printf("str2[5]char=>%cHEX=>%x\n",str[5],str[5]);printf("str2[6]char=>%cHEX=>%x\n",str[6],str[6]);printf("str2[7]char=>%cHEX=>%x\n",str[7],str[7]);//输出://str2[4]char=>oHEX=>6f//str2[5]char=>HEX=>0//str2[6]char=>HEX=>0//str2[7]char=>HEX=>0//修改字符串内容charstr3[99]="HelloWorld!";printf("%s",str3);printf(str3);str3[4]='A';printf(str3);//输出HelloWorld!HelloWorld!HellAWorld!printf("\n数组逆置:\n");intlow=0;inthigh=11;//注意上面的那个字符,11位之后就是\0了inttmp_var;while(low<high){tmp_var=str3[low];str3[low]=str3[high];str3[high]=tmp_var;low++;high--;}printf(str3);//输出://数组逆置://!dlroWAlleHcharstr4[100]="你好世界";printf("\n%s\n",str4);for(inti=0;i<13;i++){printf("%x\n",str4[i]);}/*GBK编码环境:你好世界ffffffc4ffffffe3ffffffbaffffffc3ffffffcaffffffc0ffffffbdffffffe700000你C4E3好BAC320世CAC0界BDE7*///用GBK编码显示汉字charstr5[100];str5[0]=0xc4;str5[1]=0xe3;str5[2]=0;printf(str5);//输出你}