1樓:陳舸
問題描述的不是很清楚,不過我大概猜你是想對某些結構體做排序,結構體裡有個學號的字段,要以學號為標準來排序?可以使用qsort ,隨手碼了乙份。
#include
#include
#include
typedef
struct
student
Student
;int
compare
(const
void*a
,const
void*b
)elseif(
aa->
id>bb->id)
else
}Student
*createStudent
(char
*name
,unsigned
intid
)int
main();
unsigned
intids[8
]=;Student*st
[8];for
(inti=
0;i<8;
i++)printf
("Before sorting: \n"
);for
(inti=
0;i<8;
i++)printf("
\n");qsort(st
,8,sizeof
(Student*),
compare
);printf
("After sorting: \n"
);for
(inti=
0;i<8;
i++)return0;}
C語言中不使用strcmp函式,怎麼用指標實現兩個字串的大小比較
這是微軟在UCRT中的實現,供參考 strcmp compare two strings,returning less than,equal to,or greater than Purpose STRCMP compares two strings and returns an integer t...
請問 C 語言中 和 的用法?
記住 有3個用途 1.乘號 Multiply 2 3 就是6 2.宣告指標 Pointer Statement int a 5 int ptr a 就是宣告變數a是5,把a的位址附到指標ptr上 3.解引用 Dereference ptr 單獨拿出來就是找出 ptr指標指向的值,按照第二點的說法就是...
C語言中 p p 是如何工作的?
劉博 拒絕回答好了 不要在乙個語句中多次修改同一變數的值 P大某雙學位期末考試出過請寫出f a a 的值,也是一臉懵逼,不過那門課現在已經消失了 Doraemon 我比較討厭自加 自減運算子和別的別的運算子或者判斷句同時出現,因為這樣根本搞不清參與運算的到底是自加減前的還是自加減後的,可讀性變差。自...