UrbanPro
true

Learn C Language from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Why do pointers have a datatype?

Before we start with pointers you must know what is a variable and a datatype.

int a;

This is the basic line in every program in 'C' . It means that we are asking the compiler to give us 2 bytes of space in memory and label that space as 'a'.

Now every block of memory has an address(the variable names are only to make our work easy. imagine remembering xx000345= x230989+xx0044563 instead of C= A+ B;)

This addresses can also be stored in variable and that variable is aclled pointer.

so pointers are variable storing the address of another variable.

int* b; means that "b" is going to store the address of a variable whose datatype is "int".

b=&a; // now b points to a;

Have you ever thought why do we need a datatype for a pointer even though it doesn't store a value.??

The Data type is needed when dereferencing the pointer so it knows how much data it should read. For example dereferencing a chart pointer should read the next byte from the adress it is pointing to while an int pointer should read 2 bytes.

Now what do we mean by dereferncing?

Dereferencing a pointer means getting the value that is stored in the memory location pointed by the pointer. The operator * is used to do this, and is called the dereferencing operator.

There is a lot to be discussed in pointers. like pointer to pointer, pointer arithmetic, pointer to function, object, structure array, constant pointer etc.

 We shall do that in series to follow.

0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

Income Under The Head Salary
SALARY Relationship of the receiver with payer: Income under head salary is taxable only if there is employer, employee relationship between payer and payee. And this relation is said to exist only if...
F

OOPS: Polymorphism
Polymorphism:Polymorphism (from the Greek meaning "having multiple forms") is the characteristic of being able to assign a different meaning or usage to something in different contexts - specifically,...

Contents Of C++ Programming
1. History of CPP 2. Concepts of OOP's 3. Introduction and Features of CPP (OOP's) 4. Characteristics of OOP's 5. CPP Keywords 6. Major Components of CPP: Encapsulation Inheritance Polymorphism 7....

Working with C/C++ applications
Inorder to learn C and C++ programming languages one can work with various editors available.To name a few are the most popular one is turbo c++, DEV C++, Eclipse, NetBeans. Here are the screen shots...

X

Looking for C Language Classes?

The best tutors for C Language Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn C Language with the Best Tutors

The best Tutors for C Language Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more