When I write
int main() { int j; }
The memory for j is allocated at the time of compilation, but when during compilation?
j
Compilation generates the executable code for a program. Program memory is allocated when that executable code is run.