All articles
c

A program to explain FUNCTION with RETURN TYPE POINTERS

Share this article

Share on LinkedIn Share on X (formerly Twitter)

C Programming Language 109

  • Write a program to explain FUNCTION with RETURN TYPE POINTERS

Program

#include <stdio.h>
 
int *fun()
{
    int j = 15;
    return (&j);
}
 
void main()
{
    int *b;
    b = fun();
    printf("b = %d", *b);
 
    printf("\n");
}

Result

The above code is probably incorrect. Please comment below how that can be fixed.

Comments