Search
 
SCRIPT & CODE EXAMPLE
 

C

accessing elements of 1d array using pointers

#include<stdio.h>

int main(){

    int arr[] = {1,3,4,5,6,7,8};
    int *ptr = &arr; //storing address of the first element in array in the ptr

  	//accessing the elements of the array using ptr
    for(int i=0;i<7;i++)
        printf("%d ",*(ptr+i));
  	//here i represents the value to be added to the base address
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: slug urls django 
C :: go Iterating over an array using a range operator 
C :: implicit declaration of function ‘usleep’ [-Wimplicit-function-declaration] 
C :: read a document from console in c 
C :: array reference argument 
C :: what is syntax in programming 
C :: c substring 
C :: stack push code 
C :: int to char in c 
C :: warning: function returns address of local variable [-Wreturn-local-addr] 
C :: inputting an array in c 
C :: simple calculator, using switch statement in C 
C :: Bootstrap textarea from 
C :: passing two dimensional array to function in c 
C :: adjacency matrix representation maker 
C :: addition of matrix 
C :: casting in c 
C :: how to return array of char in c 
C :: how to merge 2 bytes into an integer 
C :: square in c 
C :: Program to print all palindromes in a given range 
C :: print 0 1 2 3 4 in c while loop 
C :: how to make two arrays equal in c 
C :: size of float in c 
C :: How to send an array through a pipe 
C :: fifo page algorithm in C 
C :: how to do Employing defensive code in the UI to ensure that the current frame is the most top level window 
C :: grep C hello world 
C :: arrow keys gaming keyboard 
C :: disable gnu++11 option 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =