Assignment On Pointers
Assignment On Pointers
int main() {
return 0;
Output:-
Value of num: 10
Value of *ptr: 10
2) Pointers to array:-
#include <stdio.h>
int main() {
int arr[3] = {1, 2, 3};
int (*ptr)[3] = &arr;
return 0;
}
Output;-
Value of arr[0]: 1
Address of arr[0]: 0x7ffdd748af3c
Value of ptr: 0x7ffdd748af3c
Value of *ptr[0]: 1
3)Pointers to string;-
#include <stdio.h>
#include <stdlib.h>
int main(void){
char *a[5] = {"Hi", "I", "am", "Harsh"}; // array of pointer a having size 5 and data type as char is
created.
int i;
printf ( "The locations of the strings are:");
for (i=0; i<5; i++)
printf ("%d", a[i]);
return 0;
}
Output:-
The locations of the strings are:42025044202507420250942025120