retagged by
670 views

1 Answer

0 votes
0 votes
#include <stdio.h>    /*Include d preprocessor directive.       Header File inclusion */
int*fun()   //Function Pointer Definition or a Function returning an integer pointer 
{//Code Begins
    int x=5;//Variable Declaration 
    return &x;//Return d address of variable x 
}//Code Ends
int main(){   //Function with a return value of main
    int*p=fun(); //Here d function is called 
    fflush(stdin);//fflush is a function used to flush d //standard input. The stdin is none but our keyboard. In //case any garbage wud be there it'll be flushed out. //Especially from d buffer   
    printf("%d",*p);//Printing d value
    return 0;
}

The explanation is given in bold. The logic behind d above code is to tell d working of function pointer. If u r still not able to understand u can comment here. 

Note: *p gives d value at tat address. And &p wud give d address. Yeah. :) 

For learning sake Pointers in C by Yashwant Kanetkar is useful. 

Related questions

0 votes
0 votes
1 answer
2
Gurdeep Saini asked Feb 1, 2019
617 views
is it dangling pointer ?int main(void) { int* p;printf("%d",*p); return 0;} https://ideone.com/IN77el