Address and Dereference Operators in C Language

Dear Sciaku Learner you are not logged in or not enrolled in this course.

Please Click on login or enroll now button.

If you have any query feel free to chat us!

Happy Coding! Happy Learning!

In C language, the address operator (&) is used to obtain the memory address of a variable. The dereference operator (*) is used to access the value stored at a memory address.

The address operator (&) is placed before the variable name, and it returns the memory address of that variable. For example, if you have an integer variable x, the expression &x returns the memory address of x.

The dereference operator (*) is placed before a memory address, and it returns the value stored at that memory address. For example, if you have a pointer variable p that holds the memory address of an integer variable x, the expression *p returns the value stored in x.

Here's an example:

Copy code

#include <stdio.h> int main() {    int x = 10;    int* p = &x;    printf("The value of x is: %d\n", x);    printf("The memory address of x is: %p\n", &x);    printf("The value stored at address p is: %d\n", *p);    return 0; }

In this example, x is an integer variable with the value of 10, p is a pointer variable that holds the memory address of x, and the printf statements print the value of x, the memory address of x, and the value stored at the memory address held by p.

It's also important to mention that * operator is also called Indirection operator, and it can be used to dereference a pointer variable to access the value stored in that memory location.

8. Pointers

Comments: 0

Frequently Asked Questions (FAQs)

How do I register on Sciaku.com?
How can I enroll in a course on Sciaku.com?
Are there free courses available on Sciaku.com?
How do I purchase a paid course on Sciaku.com?
What payment methods are accepted on Sciaku.com?
How will I access the course content after purchasing a course?
How long do I have access to a purchased course on Sciaku.com?
How do I contact the admin for assistance or support?
Can I get a refund for a course I've purchased?
How does the admin grant access to a course after payment?