w1coding.comAll tutorials

C Pointers

C lessons
  1. Environment Setup
  2. Introduction
  3. Variables
  4. Operators
  5. Condition
  6. Loops
  7. Functions
  8. Arrays
  9. Pointers
  10. Strings
  11. Struct
  12. File
  13. Memory
  14. Recursions
  15. Bitwise
  16. Directives
  17. Commandline
  18. Switch
  19. Enum
  20. Structp
  21. Arraysofstr
  22. Macros
  23. Pointer Arrays
  24. Linked
  25. Stack
  26. Queue
  27. Graph

C Pointers

A pointer is a variable that stores the memory address of another variable.

Declaring and Using Pointers

#include 

int main() {
    int number = 10;
    int *ptr = &number;  // Pointer to the address of number

    printf("Value of number: %d\n", number);
    printf("Address of number: %p\n", &number);
    printf("Value of ptr: %p\n", ptr);
    printf("Value pointed to by ptr: %d\n", *ptr);
    return 0;
}
    

This program demonstrates the use of pointers by storing and accessing the address of a variable and dereferencing it.