>>1
you know it's a pointer because of the star before the name
Orly?
Is char *array[123]; a pointer too? (hint: it's an array)
When you make a pointer, you basically make a variable that holds an address instead of a value.
An address is a value. You don't "make" pointers or variables.
You define them.
Another way to declare an array is something like
char s[]
You cannot define an incomplete object, such as char s[];
And you don't declare arrays, you define them.
Learn the difference between declare and define.
The difference is that here, the array is on the stack.
Actually, C doesn't have "stacks", nor "heaps".
(like an 'if', 'while' function, etc)
if and while are keywords, not functions.
Your last snippet, in particular:
int main(void) {
char s[1024];
main();
return (0);
}
Invokes undefined behavior, it doesn't "overflow" the stack.
In particular, see 5.2.4.1 Translation limits.
Plus, a compiler is free to ignore the unused object 's', and the never reached return, and optimize right away to an infinite loop.
And that's
my lesson for you today.