C – Function returning pointer

A function returning address: A function can return address of aggregate data type variable or user defined data type variable to access the data. #include<stdio.h>int* add(int,int);void main(){            int a, b, *c;            printf(“enter two numbers : “);            scanf(“%d%d”,&a,&b);            c = add(a,b);            printf(“sum : %d\n”,*c);}int* add(int x, int y){            int z;            z=x+y;            return &z;} Dangling pointer: #include<stdio.h>int …

C – Function returning pointer Read More »

Scroll to Top