← Back to archive

Stdle #116 · storage · 2026-09-30

What does this C snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

#include <stdio.h>
int once(void) {
static int v = 0;
static int init = 0;
if (!init) { v = 41; init = 1; }
return ++v;
}
int main(void) {
printf("%d\n", once());
printf("%d\n", once());
return 0;
}
Storage
2 lines
4 attempts left

Answer & explanation