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

linux - Wie versteht man einen solchen Zeiger in der C-Sprache?
巴扎黑
巴扎黑 2017-05-16 13:25:35
0
1
696
#include <stdio.h>
int main(){
    char *params[][2] = {
        {"age", "18"},
        {"name", "小明"},
        {"address", "beij"},
        {"", ""}
    };

    printf("%s\n", params[0][0]);
    return 0;
}

Ich verstehe es nicht ganz

巴扎黑
巴扎黑

Antworte allen(1)
淡淡煙草味

每一個數(shù)組元素都是字符串。定義字符串的時候要用char *,這樣理解了吧?

當你定義一個字符串的時候,用的是char *a = "test";對吧,
那么當你定義一個字符串數(shù)組的時候,數(shù)組內(nèi)的元素是不是應該都是char *類型的。

這是定義一個字符串,你就把char *當成char來看(當然這是不對的,但是在這種情況下這樣會更好理解)。

或者直接這樣看,typedef char * string,那么這個定義就變成這樣了:

string params[][2] = {
    {"age", "18"},
    {"name", "小明"},
    {"address", "beij"},
    {"", ""}
};
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage