mikeage.net Logo
mikeage.net/2006/10/06/multiple-pointer-declarations/

mikeage.net @ ז׳ שבט תשע״ח

Multiple Pointer Declarations

Quick quiz:

What does the following code do:

char* p1, p2

?

Hopefully, you recognized that despite the fact that the asterisk is attached to the word char, we're NOT creating two character pointers. Instead, we've created one pointer (p1) and one char variable (p2). Thus, the following are legal:

*p1 = 'C';
p2 = 'd';
p1 = &p2;
p1 = malloc(10*sizeof(char));

Leave a Reply

Quick Map
Content +
Personal +
Archives +
Site Stuff +
RBS Weather +
Search +
Recent Images

Valid XHTML 1.1!
Screen Pge
 

Last Modified: September 04, 2006 @ 02:11 CST

Memory(TRUE): 4194304/4194304
Memory(FALSE): 2987176/2997160