Multiple choice

What are the types of variable f2 and p2 in the following declaration?

#define floatptr float * #define int * intptr

floatptr f1,f2; intptr p1,p2;

  1. float, int pointer

  2. float pointer, int pointer

  3. float, int

  4. float pointer, int

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The macro floatptr expands to 'float *', so 'floatptr f1,f2' becomes 'float *f1,f2'. This declares f1 as a pointer to float, but f2 as a regular float (the * only binds to f1). Similarly, 'intptr p1,p2' becomes 'int *p1,p2', making p2 a regular int. This is a classic macro pitfall.