无法弄清楚发生了什么 - C

时间:2015-12-21 20:11:23

标签: c

struct line {
    char* string;
    struct line* next;
};

有人可以解释一下发生了什么吗? 例如:

  • 创建结构" line"

  • 这个结构有一个char变量" string" - >什么是" *" ??

  • 在这个结构中,我们创建了一个名为" line *" - >什么是" *" ??

  • 新结构有一个字段" next"

2 个答案:

答案 0 :(得分:4)

基本上,您的结构中的stringline不是数据项,而是指针到内存中实际数据项所在的位置。

您可以在此tutorial on pointers in C了解详情。

答案 1 :(得分:1)

interp2d

参考本教程 http://www.cprogramming.com/tutorial/c/lesson6.html

此处struct line { // create structure char* string; // here * represent pointer and this line creates character pointer named string struct line* next; // create pointer to structure named next }; 是结构。

在其中,您正在创建指向line的指针,指针名称为line

相关问题