
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to change the output of printf() in main()?
Here we will see how to change the output of the printf() function from main(). Here we will define a function that will change all of the printf() statements with the given type to another type.
We will use the #define macro to do this task. This macro will be defined inside the function. We can directly put the #define line without using it in the function, but in that case always the printf() will be changed. To control it using main, we have to call the function first.
Example
#include <stdio.h> void changePrintf() { //always any printf will print 50 #define printf(x, y) printf(x, 50); } main() { int x = 40; changePrintf(); printf("%d\n", x); x = 60; printf("%d", x); }
Output
50 50
- Related Questions & Answers
- How to change the Output Encoding Scheme of the C# Console?
- How to change the font size of main title of boxplot in base R?
- Can we change the order of public static void main() to static public void main() in Java?
- How to change the order of independent variables for regression summary output in R?
- How to print % using printf()?
- Return the identity array and change the datatype of the output in Numpy
- Can we change return type of main() method in java?
- What is the use of %n in printf()?
- How to use printf () in Android sqlite?
- How to change the order of one column data frame and get the output in data frame format in R?
- What is the use of `%p` in printf in C?
- How to use the Main() method in C#?
- Execution of printf with ++ operators in C
- printf() function in PHP
- How to view the complete output of tibble in R?
Advertisements