#include <stdio.h> #include <stdlib.h> int main() { int n; scanf("%d",&n); while(1) { scanf("%d",&n); if(n==42) break; printf("%d",n); } return 0; }
Remove first scanf()
For this input:
1 2 3 42
Your code prints:
2 3
For this input your code returns a NZEC.
42 1 2 3