C Programming - Functions - Discussion

Discussion Forum : Functions - Point Out Correct Statements (Q.No. 1)
1.
Which of the following statements are correct about the program?
#include<stdio.h>

int main()
{
    printf("%p\n", main());
    return 0;
}
It prints garbage values infinitely
Runs infinitely without printing anything
Error: main() cannot be called inside printf()
No Error and print nothing
Answer: Option
Explanation:

In printf("%p\n", main()); it calls the main() function and then it repeats infinetly, untill stack overflow.

Discussion:
15 comments Page 2 of 2.

Prashanth said:   9 years ago
Output : Segmentation fault (core dumped).

Cheeku said:   9 years ago
It will print the address of main.

Jayanti said:   6 years ago
Here, Segmentation fault error.

Varun said:   1 decade ago
Thank you. @Rupinderjit.

Lav said:   1 decade ago
What is %p ?


Post your comments here:

Your comments will be displayed after verification.