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

Fácil 10 perguntas ~5 minutos Aprovação com 80% C17

Escolha um modo

Jogando como visitante: entre para guardar seu XP e sua sequência.

Pergunta de exemplo

Pergunta 1 de 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;
}
Mostrar a resposta

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

O que este quiz cobre

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

Perguntas frequentes

Preciso de uma conta?

Não. Qualquer pessoa pode jogar. Entre para guardar seu XP, sequência, badges e histórico.

Posso refazer?

Pode. Sua melhor nota fica salva, e as perguntas e respostas são embaralhadas a cada vez.