- Executores
-
Aprender
Aprender Python Exemplos executáveis, NumPy, pandas e mais Aprender IA / Machine LearningRedes neurais, ML e LLMs do zero Aprender C e C++ Ponteiros, memória, STL e C++ moderno Aprender C#Fundamentos, POO, LINQ, async e exercícios .NET Aprender MatplotlibGráficos de linha, barras, dispersão e pizza com visualizadores Aprender RustOwnership, traits, tratamento de erros e threads Aprender GoSlices, interfaces, goroutines e channels Algoritmos em Python Busca, ordenação, recursão e visualizações O(n) Algoritmos em C e C++ Compare implementações em C e C++ Programação para crianças Aprenda a programar brincando!
- QuizzesNovo
- DesafiosNovo
- Para professoresNovo
- Atualizações
- Me pague um café
Quiz de C: Buffer Overflows & Bounds
C does not check array bounds, so one wrong index can corrupt memory or open a security hole. This quiz shows realistic snippets and asks you to spot off-by-one errors, unsafe string calls and sneaky signed/unsigned comparisons, and pick the safe fix.
Pergunta de exemplo
Pergunta 1 de 10What is the bug in this code?
#include <stdio.h>
int main(void) {
int a[5];
for (int i = 0; i <= 5; i++) {
a[i] = i * i;
}
printf("%d\n", a[4]);
return 0;
}
Mostrar a resposta
D. i <= 5 writes to a[5], one element past the end A 5-element array has indexes 0 to 4, so the last iteration writes a[5], outside the array. The fix is i < 5; the <= off-by-one is one of the most common overflow causes.
O que este quiz cobre
- Off-by-one loops and the missing terminator byte
- What undefined behaviour means for an out-of-bounds write
- Unsafe calls:
gets,strcpywithout a size check - Bounded alternatives:
fgets,snprintf, explicit checks - Finding bugs with
-fsanitize=address
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.