Pointers and Arrays in C

  • Post author:
  • Post category:c
  • Post comments:0 Comments

Pointers and Arrays in C

In this lesson, you will learn about pointers and arrays in C programming. Pointers are used to store the memory address of a variable and can be used to manipulate the data stored at that address. Arrays are used to store multiple values of the same type in a single variable. You will learn how to declare, define, and access pointers and arrays.

Example

#include <stdio.h> 

int main() 
{ 
    int arr[5] = {1, 2, 3, 4, 5}; 
    int *ptr; 
  
    ptr = arr; 
  
    for(int i = 0; i < 5; i++) 
        printf("%d ", *(ptr + i)); 
  
    return 0; 
} 

Output

1 2 3 4 5

Leave a Reply