![]() ![]() 10 questions about dynamic memory allocation.Interview questions on bitwise operators in C How to find maximum or minimum between three numbers using ternary operator Enter any two number to check max and min: 10 20 MAX (10, 20) 20 MIN (10, 20) 10.The maximum allowed bit-width of an integer type is 65535. You should know the volatile Qualifier. C Translation Caching Translation failures C Macros C Pointers C Variadic Functions.Difference between typedef and #define ( typedef vs #define).Printf("Current Time(HH:MM:SS) :%s\n", _TIME_ ) ![]() Printf("Current Date(MMM DD YYYY) :%s\n", _DATE_ ) _TIME_ current time in "HH:MM:SS" format. _DATE_ current date in "MM DD YYYY" format. The following is the list of some predefined Macros which you should know. Printf("\n\nValue of a and b After swaping\n") Printf("Value of a and b before swaping\n") We can also create a function as a macro in multi-line, See the below example in which I am swapping the value of two variables. You should remember the following points before using the function-like a macro in c.Always remember there is no type checking occur in macro.You should never use a function like macro if you can use the function.Use each macro parameter once to avoid the undesired side effect.Always use proper parentheses in macro.You should remember the following points before using the function-like a macro in c. Note: You can See, Token Pasting Operator It increases the code readability.įor example, #define MAX(A, B) (((A) > (B)) ? (A) : (B)) Like if you are creating a macro to represent the second, you should write the macro name SECOND. It is mainly used to give a symbolic name to a numeric constant and it is a good habit to give a meaningful name to a numeric constant. Basically, there are two types of macros, object-like macros, and function-like macros.Īn object-like macro is a simple identifier that will be replaced by a code segment (a piece of code) in the program. ![]() These replacements occur before the compilation of the code which is the reason there is no type checking occurring with C macros. In my code where I will use “ATICLEWORLD”, it is replaced with 24. Whenever in a program we used the macro name, it is replaced by the contents of the macro. In C programming macro is a segment of the code that has some unique name. You will also learn to use #define with some predefined C Macros with the help of programming examples. We will discuss here the types of C macro (object and function). In this tutorial, you will learn the C Macros with programming examples. The macro name is MAXSIZE and it is abbreviated for the constant 1000. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |