Uploaded November 2026 | Updated November 2026, 3 days ago
Learn how to write Pointer Declarations in C programming using different coding styles and understand why the placement of the asterisk (*) matters when declaring multiple variables.
In this beginner-friendly tutorial, we first review how to declare a Pointer to int and how a pointer variable can store the memory address of an integer object.
Next, we explore different ways of writing Pointer Declarations in C. We compare three common declaration styles:
1. int *ptr;
2. int* ptr;
3. int * ptr;
We explain why all three declarations are valid in C and why they create the same type of pointer variable.
We also discuss coding style and consistency. Different programmers prefer different spacing conventions, but it is important to follow a consistent declaration style throughout your program.
After that, we explore an important issue that can occur when declaring multiple variables in a single declaration statement.
Using the declaration int* ptr, ptr2;, we explain why ptr is a Pointer to int while ptr2 is a normal integer variable, even though the declaration may appear to define two pointers.
We demonstrate that the asterisk (*) is associated with each individual declarator rather than automatically applying to every variable declared in the statement.
Next, we use the sizeof Operator and printf() to compare the sizes of the declared variables with sizeof(int *) and sizeof(int).
In the demonstrated implementation, a Pointer to int occupies 8 bytes, while an int variable occupies 4 bytes. These sizes are implementation-dependent and may differ on other systems.
We then correct the multiple-pointer declaration by writing int *ptr, *ptr2;, which declares both variables as Pointers to int.
Finally, we discuss why the declaration style int *ptr is used throughout this C programming course and how it can help make declarations involving multiple variables easier to understand.
This tutorial helps you understand Pointer Declaration Syntax, Asterisk Placement, Multiple Pointer Declarations, sizeof, and common mistakes when declaring pointers in C programming.
Our Website
LearningLad.com
Social Media
Facebook facebook.com/LearningLad
Twitter twitter.com/LearningLadEdu
Instagram instagram.com/LearningLadOfficial
Learn how to write Pointer Declarations in C programming using different coding styles and understand why the placement of the asterisk (*) matters when declaring multiple variables.
In this beginner-friendly tutorial, we first review how to declare a Pointer to int and how a pointer variable can store the memory address of an integer object.
Next, we explore different ways of writing Pointer Declarations in C. We compare three common declaration styles:
1. int *ptr;
2. int* ptr;
3. int * ptr;
We explain why all three declarations are valid in C and why they create the same type of pointer variable.
We also discuss coding style and consistency. Different programmers prefer different spacing conventions, but it is important to follow a consistent declaration style throughout your program.
After that, we explore an important issue that can occur when declaring multiple variables in a single declaration statement.
Using the declaration int* ptr, ptr2;, we explain why ptr is a Pointer to int while ptr2 is a normal integer variable, even though the declaration may appear to define two pointers.
We demonstrate that the asterisk (*) is associated with each individual declarator rather than automatically applying to every variable declared in the statement.
Next, we use the sizeof Operator and printf() to compare the sizes of the declared variables with sizeof(int *) and sizeof(int).
In the demonstrated implementation, a Pointer to int occupies 8 bytes, while an int variable occupies 4 bytes. These sizes are implementation-dependent and may differ on other systems.
We then correct the multiple-pointer declaration by writing int *ptr, *ptr2;, which declares both variables as Pointers to int.
Finally, we discuss why the declaration style int *ptr is used throughout this C programming course and how it can help make declarations involving multiple variables easier to understand.
This tutorial helps you understand Pointer Declaration Syntax, Asterisk Placement, Multiple Pointer Declarations, sizeof, and common mistakes when declaring pointers in C programming.
Our Website
LearningLad.com
Social Media
Facebook facebook.com/LearningLad
Twitter twitter.com/LearningLadEdu
Instagram instagram.com/LearningLadOfficial









