#include <stdio.h>
int main(){
char *params[][2] = {
{"age", "18"},
{"name", "小明"},
{"address", "beij"},
{"", ""}
};
printf("%s\n", params[0][0]);
return 0;
}
I don’t quite understand
淡淡烟草味2017-05-16 13:27:35
Each array element is a string. You need to use char *
when defining a string. Do you understand this?
When you define a string, you use char *a = "test";
right,
then when you define a string array, the elements in the array are Not all should be of the char *a = "test";
对吧,
那么当你定义一个字符串数组的时候,数组内的元素是不是应该都是char *
type.
This is defining a string, you can view char *
当成char
as char
(of course this is wrong, but in this case it will be better understood).
Or look at it like this, typedef char * string
, then the definition becomes like this:
string params[][2] = {
{"age", "18"},
{"name", "小明"},
{"address", "beij"},
{"", ""}
};