
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Pointer vs Array in C
Pointers and array most of the time are treated as same in c. Some differences are:
&operator:
&pointer = returns the address of pointer.
&array = returns the address of first element.
sizeof operator:
sizeof(array) = returns the total memory consumed by the all the elements of the array.
sizeof(pointer) = returns the only memory consumed by the pointer variable itself.
Array variable can’t be re-assigned a value whereas pointer variable can.
Declaration:
int a[]; //array Int *p; //pointer
Let us consider that there is an integer pointer variable
int *i;
Now let us consider the outcome of the following assignments –
a = &i; //illegal assignment. a variable can not be updated or modified. p = &i; //legal assignment.
Advertisements