ByTime 发表于 2020-2-28 20:57:00

{:9_221:}感觉越来越迷惑&和指针*的区别了

ByTime 发表于 2020-2-28 21:00:16

#include <stdio.h>
#include <stdlib.h>

typedef char ElemType;

typedef struct QNode
{
    ElemType data;
    struct QNode *next;
} QNode, *QueuePtr;

typedef struct
{
    QueuePtr front, rear;
} LinkQueue;

initQueue(LinkQueue *q)
{
    q->front = q->rear = (QueuePtr)malloc(sizeof(QNode));
    if( !q->front )
      exit(0);

    q->front->next = NULL;
}

int main()
{
    ElemType e;
    LinkQueue *q,Q;
    initQueue(q);//运行不了
    initQueue(&Q);//可以运行
    return 0;
}

人造人 发表于 2020-2-28 21:00:52

去学汇编语言吧,带上汇编语言学数据结构与算法

ByTime 发表于 2020-2-28 21:01:22

为什么
initQueue(q);不能运行?q不是也是LinkQueue的地址么?

人造人 发表于 2020-2-28 21:02:57

你还是没有彻底理解C语言的指针,去学汇编语言吧,去看一看汇编语言层的指针

ByTime 发表于 2020-2-28 21:03:19

人造人 发表于 2020-2-28 21:00
去学汇编语言吧,带上汇编语言学数据结构与算法

{:9_221:}就是想知道这两个的区别嘛

人造人 发表于 2020-2-28 21:03:42

你引用了未初始化的变量

ByTime 发表于 2020-2-28 21:06:41

人造人 发表于 2020-2-28 21:03
你引用了未初始化的变量

我懂惹
页: [1]
查看完整版本: 关于C的数据结构的问题