Pointer Declaration in C | int *ptr vs int* ptr & Multiple Pointer Variables @LearningLad
Pointer Declaration in C | int *ptr vs int* ptr & Multiple Pointer Variables  @LearningLad
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
Pointer Declaration in C | int *ptr vs int* ptr & Multiple Pointer VariablesReturn Statement in C Explained | return, Unreachable Code & break vs returnDefining Structures Variables in Different ways in C Programming Language | TutorialSquare Pattern Printing with Diagonals in C Programming Language TutorialHow to install NumPy SciPy Pandas Matplotlib libraries for Python in Windows 10typedef in C Explained | Type Aliases, Enums & Scopefprintf() Function to Write Data to a File :  C Programming Language Video TutorialInternal Working of For, While & Do While Loops in C | Explained with ExamplesCalling One Function From Another in C | Function Control Flow ExplainedHow to Install Code::Blocks IDE & MinGW on Windows for C/C++ ProgrammingContinue Statement in C Programming | Skip Current Iteration with Example
LearningLad |

Pointer Declaration in C | int *ptr vs int* ptr & Multiple Pointer Variables

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER