国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

linux - How to understand such a pointer in C language?
巴扎黑
巴扎黑 2017-05-16 13:25:35
0
1
695
#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

巴扎黑
巴扎黑

reply all(1)
淡淡煙草味

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";對(duì)吧,
那么當(dāng)你定義一個(gè)字符串?dāng)?shù)組的時(shí)候,數(shù)組內(nèi)的元素是不是應(yīng)該都是char * type.

This is defining a string, you can view char *當(dāng)成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"},
    {"", ""}
};
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template