C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs

Home » C programming language

Pointer and non-pointer variables declarations together in C?

Learn: How to declare pointer and non-pointer variables together using single declaration statement in C/C++ programming language?

Let suppose, if you want to declare three variables in which two are pointers and one is not a pointer variable, we can declare them in a single line declaration statement.

Consider the following declaration:

int *ptr_a,*ptr_b,c;

ptr_a - is an integer pointer
ptr_b - is an integer pointer
c - is an integer pointer (a non-pointer variable)

Declaration of integer array and pointer to array together (using single declaration statement)

Consider the given declaration statement:

int arr[100], *ptr;

arr[100] - is an integer array with 100 elements ptr - is an integer pointer (pointer to an array)

Liked this article? Do share with your friends :)