Quiz di 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.

Facile 10 domande ~5 minuti Superato con il 80% C17

Scegli una modalità

Stai giocando come ospite: accedi per salvare XP e serie.

Domanda di esempio

Domanda 1 di 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;
}
Mostra la risposta

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

Cosa copre questo quiz

  • 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 ==

Domande frequenti

Serve un account?

No. Chiunque può giocare. Accedi per salvare XP, serie, badge e cronologia.

Posso rifarlo?

Sì. Il tuo miglior punteggio resta salvato, e domande e risposte vengono mescolate ogni volta.