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)

Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.

Comments and Discussions

We are using Google to publish ads on our website; Google has its own privacy policies. They may save log, cookies on your system. Google may also collect information of your system like IP address, region, city, country. For more details please go through the Google’s privacy policy.