Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

POINTERS, STACK, CODESPACE, ETC

Name: Anonymous 2008-05-25 17:58

http://i30.tinypic.com/2z5itg5.jpg

Read and enjoy the lesson

Name: Anonymous 2008-05-25 18:26

>>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.

Name: Anonymous 2008-05-25 18:44

>>4
1.  char *array[123] IS a pointer.  It points to the head of an array of strings.
No, char *array[123] is an array of 123 pointers to char.
A pointer to an aray of 123 char would be char (*array)[123]
2.  Define and make are interchangeable terminology.
Not according to the standard.
3.  GODDAMN, you don't know what the 'stack' and 'heap' are in memory hierarchy??  fucking just kill yourself now.
They don't exist in the standard.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List