首页 > 编程知识 正文

字符串数组初始化,初始化二维数组

时间:2023-05-04 13:33:57 阅读:168102 作者:3648

埃里克里斯钦.

9

如何创建包含字符指针的数组大小5:

char *array_of_pointers[ 5 ]; //array size5containingpointerstochar

char m='m '; //charactervalueholdingthevalue ' m '

array_of_pointers[0]=m; //assignmptrintothearrayposition 0。

printf('%c”,*array_of_pointers[0]; //get the value of the pointer to m

如何创建指向字符数组的指针:

char(*pointer_to_array ) [ 5 ]; //apointertoanarraycontaining5chars

char m='m '; //charactervalueholdingthevalue ' m '

printf(%c ),) * pointer _ to _ array [0]; //dereferencearrayandgetposition 0

如何创建包含字符指针的二维阵列:

char *array_of_pointers[5][2];

//an array size5containingarrayssize2containingpointerstochar

char m='m ';

//charactervalueholdingthevalue ' m '

array_of_pointers[4][1]=m;

//Get position 4 of array,then get position 1,then put m ptr in there。

printf('%c ',*array_of_pointers[4][1] );

//Get position 4 of array,thengetposition1anddereferenceit。

如何创建指向二维数组字符的指针:

char(*pointer_to_array ) [5][2];

//apointertoanarraysize5eachcontainingarrayssize2whichholdchars

char m='m ';

//charactervalueholdingthevalue ' m '

(*pointer_to_array ) [4][1]=m;

//dereference array,Get position 4,get position 1,put m there。

printf(%c ),) *pointer_to_array ) [4][1];

//dereference array,Get position 4,get position 1

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。