二维字符数组初始化
通常情况下,二维数组的每一行分别使用一个字符串进行初始化例如
1. char arr[][10]={{"apple"),{"orange"},{"banana"}};
2. char arr[][10]={"apple", "orange","banana"}:
3. char arr[[10]={"apple","orange", "banana"};
4. char arr[3][10]= {{a', 'p', 'p', I','e}.
{o','r','a','n','g','e'},
{'b','a', 'n','a','n', 'a'l}:
二维字符数组的输入
输出
字符指针数组
char arr[5][10] {"hello", "happy ","world", "byebye", "see you"};
charpstr[5];//指针数组
pstr[] -arr[];
pstr[1] -arr[];
pstr[3] -arr[3]
pstr[4]=arr[4];
scanf_char(pstr,5,10);
二维字符数组传参
void scanf_char(char(p)[10]int row, int colume//char arr[10]//数组指针传参
{
int i;
for(i=0; i<row; i++)
{
scanf("%s", p[i]);
}
#include <stdio. h>
#include <stddef. h>
#include <string. h>
void test sizeof_arr2(void)
inta[3][4]=0
printf("%#p\n",a);
printf("%d\n", sizeof(a));
printf("%d\n", sizeof([] [0]));
printf("%d\n", sizeof([]));
printf("%d\n", sizeof([] +0));
printf("%d\n", sizeof([] +1));
printf("%\n", sizeof(([] 1)));
printf("%\n", sizeof(a +1));
/printf("%#p\n",a);
printf("%#p\", a+1);
/ printf("%d\n", sizeof((a 1)));
/ printf("%#p\", (a 1));
printf("%#p\n", a[o])
printf("%d\n", sizeof(&[0] 1));
printf("%#p\n", &[]);
printf("%#p\n", &a []+1);
printf("%d\n", sizeof(*(&a[]+ 1)));
printf("%d\n", sizeof(a));
printf("%\n", sizeof([3]))
}
void test_strlen str(void)
{
char arr[]="abcdef"; //{'a','b', 'c','d','e','f', '\o'}
printf("%d\n", strlen(arr));
printf( "%d\n", strlen(arr+0));
/ printf("%d\", strlen(*arr));
/ printf( "%d\n", strlen(arr[1]));
printf("%d\n", strlen(&arr));
printf("%d\n", strlen(&arr+ 1));
printf("%d\n", strlen(&arr [0] 1));
void test_sizeof str(void)
{
char arr[] ="abcdef";
printf("%\n", sizeof(arr));
printf("%#\ n", arr) i