Quick links
Latest articles
Internship
Members
New...
Algorithms
Discrete Mathematics
Big data
Languages
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL
Web
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.
Programs
C
C++
DS
Java
C#
Python
Aptitude
C
C++
Java
DBMS
Interview
C
Embedded C
Java
SEO
HR
CS Subjects
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS
More...
Articles
Puzzles
News/Updates

Home » C programs » C pointer programs

C program to print size of different types of pointer variables.



In this C program, we will check what will be the size of different types of pointer variables? Here, we will print the size of different types of pointer variables.
Submitted by IncludeHelp, on April 26, 2018

Any type of pointer variable takes the same memory bytes in the memory, because they are used to store the memory addresses on other type of variables.

Let’s take an example - There are two pointers 1) integer pointer and 2) char pointer, integer pointer will take 4 bytes (in case of, 32 bits compiler) and will store the address of integer variables only. char pointer will also take 4 bytes but it will store the address of only char variable.

In this C program, we are testing the same by printing the size of different types of pointers.

C program to print sizes of different type of pointers



/*C program to print size of different types of pointer variables.*/
#include <stdio.h>
 
int main()
{
    printf("\nsize of char pointer: %d"     ,sizeof(char*));
    printf("\nsize of int pointer: %d"      ,sizeof(int*));
    printf("\nsize of float pointer: %d"    ,sizeof(float*));
    printf("\nsize of long int pointer: %d" ,sizeof(long int*));
    printf("\nsize of double pointer: %d\n" ,sizeof(double*));
    return 0;
}

Output

    size of char pointer: 4
    size of int pointer: 4
    size of float pointer: 4
    size of long int pointer: 4
    size of double pointer: 4

~~~~ Output depends on the system architecture,
~~~~ but each type of pointer will take same memory space ~~~






Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Featured post:
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distribution Software (Distros) of 2018

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com (2015-2018), Some rights reserved.