Difference between Macros and Functions in C

Question: What are Differences Between Macros and Functions in C Language? Answer: Macros are like functions but don’t act like functions. For ex., #define MAX(a,b) ((a) > (b) ? (a) : (b)) When used in program, preprocessor substitutes macro MAX(a,b) with it’s definition wherever it appears in program. For ex., int main(void) { int x … Read more

advertisement

Macros in C with Examples

This C Tutorial explains Macros in C with examples. Macros are like functions but aren’t true functions. By using macros, you can avoid repeating code and make your code more readable. To create a macro, you use the #define preprocessor directive. You can undefine a macro using the #undef directive. Syntax of Macros: #define MACRO_NAME … Read more

advertisement

What is #define Directive in C Program?

This C Tutorial explains #define Directive in a C Program. #define directives are preprocessor directives. These are either symbolic constants or macros or conditional compilation constructs or other various directives. Let’s see first symbolic constants, for ex., #define NAME "What is your name?" #define SIZE 512 #define PI 3.14   #define FOREVER for(;;) #define PRINT … Read more

advertisement

What are Preprocessor Directives in C?

This C Tutorial explains Preprocessor Directives or Symbols and their Uses in a C Program. Every C program contains one or more functions which are prototyped in standard library header files. To use functions we need to include them in program. This inclusion is done by preprocessor directives #include. Preprocessor when operates on the source … Read more

advertisement

What is C Preprocessor?

This tutorial explains what is C Preprocessor with examples. Question: What is a C Preprocessor? Answer: Preprocessor is a program that performs textual substitutions on source code even before the program is compiled. Basically, this deletes the comments, inserts the code of specified #included headers into the program, defines and substitutes the #define symbols and … Read more

advertisement

How to Compile C Program in Linux?

This C Tutorial explains Steps Involved in Compiling a C Program on Linux System. Let’s understand GCC Compilation Process which comprises of following steps. 1. Preprocessing 2. Compilation 3. Assembly 4. Linking 5. Program Translation Before talking of compiling and running C program in Linux let’s see why C is so popular ever since it … Read more

advertisement

Difference between Preprocessor and Compiler

Question1: What is Difference between Preprocessor and Compiler? Answer: Though, the preprocessor is the first to look at the source code file and performs several preprocessing operations before it’s compiled by the compiler. Nevertheless, compiler sets the source code file, say “hello.c”, through several phases of translation before jumps into preprocessing. Actually, it prepares the … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.