C
Chris Mantoulidis
I never liked pointers really much, so I decided to stay away from
them for a while. I know they're useful, so now I decided to actually
learn how the work, use them, etc.
Here's my question...
char *a = "some text";
char *b = "some other text";
Why will this work? Needn't I initialize the pointers first? (malloc
in C, new in C++, whatever)
And second question. Let's say I got a function that returns char *
("odd" if the parameter is odd, and "even" if the parameter is even)
char *s1 = CHAR_PTR_FUNCTION(1);
char *s2 = CHAR_PTR_FUNCTION(2);
The return value (returned like 'return "odd"' or 'return "even"'),
where is it stored? It has to be stored somewhere cuz otherwise *s1
would have the same value as *s2...
I'm getting confused here...
Any help?
them for a while. I know they're useful, so now I decided to actually
learn how the work, use them, etc.
Here's my question...
char *a = "some text";
char *b = "some other text";
Why will this work? Needn't I initialize the pointers first? (malloc
in C, new in C++, whatever)
And second question. Let's say I got a function that returns char *
("odd" if the parameter is odd, and "even" if the parameter is even)
char *s1 = CHAR_PTR_FUNCTION(1);
char *s2 = CHAR_PTR_FUNCTION(2);
The return value (returned like 'return "odd"' or 'return "even"'),
where is it stored? It has to be stored somewhere cuz otherwise *s1
would have the same value as *s2...
I'm getting confused here...
Any help?