How to Change the Output of printf() in main() in C?
To change the output of printf() in main(), we can use Macro Arguments.
#define macro can be used for this task. This macro is defined inside the function. Although, #define can be used without declaring it in the function, in that case always the printf() will be changed. The function needs to be called first to change the output of printf() in main().
Consider the following program. Change the program so that the output of printf() is always 10.
It is not allowed to change main(). Only fun() can be changed. Now, consider the following program using Macro Arguments,
Time Complexity: O(1)
Auxiliary Space: O(1)
This article is contributed by Abhay Rathi. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.