小编Cla*_*zzi的帖子

如何在C中对结构数组进行排序?

我又来了。我在尝试对c中的结构数组进行排序时遇到问题,我知道我的代码不够好,但是请不要对我不礼貌!

我尝试更改函数参数,但我已经筋疲力尽了,我敢肯定,如果我继续的话,我会做更多的错误,所以我需要您的帮助。

这是我程序的完整代码 https://pastebin.com/p28EbY8i

// I've 2 struct 

typedef struct{     // Not used in this function
    int id;
    char * nome;
    char * presidente;
    char * allenatore;
} squadra;

typedef struct{     // I've an array of this type of data
        int id;
        char * nome;
        char * cognome;
        int eta;
        char * ruolo;
        squadra team;
        char * college;
        int td;
    } giocatore;

// This is what i wrote for my function

size_t ordina_classifica(size_t sz, giocatore array[]){  //sz is the array …
Run Code Online (Sandbox Code Playgroud)

c arrays sorting struct qsort

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

标签 统计

arrays ×1

c ×1

qsort ×1

sorting ×1

struct ×1