How to find the value at an address location in the memory using C pointers??

Recommended Answers

All 2 Replies

You mean something like this?

int x = 123;
int* pX = &x;
printf("%d\n", *px);

How to find the value at an address location in the memory using C pointers??

The '&' sign means address of and the '*' sign means value at. So when you need to find the value at an address point. You first need to declare a pointer. I mean something like this.

int *numPtr;

This creates a pointer called numPtr. Pointers can be used to store addresses. So that the expression;

int num;
numPtr = num;

means the address of the variable of type int has been assigned to numPtr. That is numPtr represents the address. But when you need its value you need to add the '*' sign to it since it means value at.
I hope you understand it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.