In one of the answers to Golf Tips in C , I saw this code (ungolfed version):
s[],t; main(c){ for(scanf("%*d "); ~(c=getchar()); s[t++]=c) putchar(s[t]); }
I think the above program shows UB (but who cares about code golf?). But I do not understand that it is s[] on a global scale. I know that when the type of a global variable is not specified, it defaults to int . I created a small program that compiles unexpectedly:
#include <stdio.h> int s[]; int main(void) { printf("Hello!"); }
although it gives one warning:
prog.c:23:5: warning: array 's' assumed to have one element [enabled by default] int s[]; ^
- What is
s in the above program? Is it int* or something else? - Would it be useful anywhere?
source share