mikeage.net Logo

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!
Printer Friendly Page

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

Memory(TRUE): 2097152/2097152
Memory(FALSE): 2799192/2809144