相关疑难解决方法(0)

有人可以解释指针指针的工作原理吗?

我真的不明白指针指针是如何工作的.没有使用指针指针的任何方式做同样的工作?

struct customer
{
    char name[20];
    char surname[20];
    int code;
    float money;
};
typedef struct customer customer;
void inserts(customer **tmp)
{
    *tmp = (customer *)malloc(sizeof(customer));
    puts("Give me a customer name, surname code and money");
    scanf("%s %s %d %f", (*tmp)->name, (*tmp)->surname, &(*tmp)->code, &(*tmp)->money);
}
Run Code Online (Sandbox Code Playgroud)

c malloc struct pointers

2
推荐指数
1
解决办法
227
查看次数

为什么这个C链表程序会给出"分段错误"?

第一个函数读取一个包含一堆'char'的文件,并将它们放在一个链表中.它无法正常工作:(.

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

struct list {
    char val;
    struct list* next;
};

typedef struct list element;

int lcreate(char* fname, element* list);
int ldelete(element* list);
int linsert(char a, char b, element* list);
int lremove(char a, element* list);
int lsave(char* fname, element* list);



int lcreate(char* fname, element* list) {
    element* elem = list;
    char c = 0;
    FILE * file = NULL;

    file = fopen(fname, "r");

    while ((c = getc(file)) != EOF)
    {
        if(list == NULL) {
            list = (element*)malloc(sizeof(element)); …
Run Code Online (Sandbox Code Playgroud)

c linked-list

0
推荐指数
1
解决办法
692
查看次数

标签 统计

c ×2

linked-list ×1

malloc ×1

pointers ×1

struct ×1