- 401 名前:デフォルトの名無しさん mailto:sage [2013/05/04(土) 18:57:22.47 ]
- Head First Cという本で勉強しているのですが構造体で詰まりました。
下記のra->width、ra->heightの値は定義していないように見えるのですが いったいいつ定義しているのでしょうか? typedef struct{ int width; int height; } rectangle; int compare_areas(const void* a, const void* b) { rectangle* ra = (rectangle*)a; rectangle* rb = (rectangle*)b; int area_a = ra->width * ra->height; int area_b = rb->width * rb->height; return area_a - area_b; } int main() { int i; int scores[] = {543, 323, 32, 554, 11, 3, 112}; qsort(scores, 7, sizeof(int), compare_areas); return 0; }
|

|