C クイズ: Structs & typedef

Structs are how C groups related values into one type. This easy quiz covers declaring and initialising structs, copying them, nesting them, the -> operator and typedef, with a look at why struct sizes can surprise you.

やさしい 10問 約5分 合格ライン 80% C17

モードを選ぶ

ゲストとしてプレイ中です。ログインすると XP と連続記録が保存されます。

例題

第1問 / 全10問

What does this print?

#include <stdio.h>

struct point {
    int x;
    int y;
};

int main(void) {
    struct point p = {3, 7};
    printf("%d %d\n", p.x, p.y);
    return 0;
}
答えを見る

A. 3 7 A brace initializer fills the members in the order they are declared, so x gets 3 and y gets 7.

このクイズの内容

  • Declaring structs and initialising them, including designated initializers
  • Struct assignment copies every member
  • Nested structs and the -> operator
  • typedef for shorter type names
  • Padding and why you cannot compare structs with ==

よくある質問

アカウントは必要ですか?

いいえ、誰でも遊べます。ログインすると XP、連続記録、バッジ、履歴が保存されます。

何度でも挑戦できますか?

はい。ベストスコアが記録され、問題と選択肢は毎回シャッフルされます。