C Command Line Arguments

Command line arguments are passed inside the main function of a C program also called as command line of the C program, hence the name, command line arguments. Syntax: data_type main(int argc, char *argv[] ) Argc: This is a mandatory parameter that counts the number of arguments. Argv[]: This is also a mandatory parameter that … Read more

Categories C

c preprocessor pragma

C #pragma: The #pragma is a preprocessor directive which is used to get additional information related to machine or operating-system features by the compiler. Some of the commonly used #pragma directives are: #pragma argsused #pragma exit #pragma hdrfile #pragma hdrstop #pragma inline #pragma option #pragma saveregs #pragma startup #pragma warn   Syntax: #pragma_directives identifiers Example: … Read more

Categories C

c preprocessor error

C #error: The #error is a preprocessor directive in C which is used to display an error if #error directive is found during the code execution and thus stops any further compilation of the code. Example: #include<stdio.h> #ifndef AGE #error First define then compile #else void main() { printf("%d",AGE); } #endif#include<stdio.h> #ifndef AGE #error First … Read more

Categories C

c preprocessor else

C #else: The #else is a preprocessor directive in C which is used with, #if to execute a piece of code, only if the specified condition is FALSE. #ifdef to execute a piece of code, only if the specified macro is not defined. #ifndef to execute a piece of code, only if the specified macro … Read more

Categories C

c preprocessor if

C #if: The #if is a preprocessor directive in C which is used to execute a piece of code, only if the specified condition is TRUE. Syntax: #if condition // code to be executed if condition is TRUE. #endif OR #if condition //  code to be executed if condition is TRUE. #else //  code to … Read more

Categories C

c preprocessor ifndef

C #ifndef: The #ifndef is a preprocessor directive in C which is used to execute a piece of code, only if the specified macro is not defined by #define. Syntax: #ifndef MACRO // code to be executed if macro is not defined #endif OR #ifndef MACRO // code to be executed if macro is not … Read more

Categories C

c preprocessor ifdef

The #ifdef is a preprocessor directive in C which is used to execute a piece of code, only if the specified macro is already defined by #define. Syntax: #ifdef MACRO // code to be executed if macro is defined #endif OR #ifdef MACRO // code to be executed if macro is defined #else // code … Read more

Categories C

c preprocessor undefine

C #undef: A macro value in C replaces a part of a program with a value already defined by #define directive. The #undef is a preprocessor directive which is used to undefine the value defined by #define. Syntax: #undef macro_Name Example: #include<stdio.h> #define e 2.718 #undef e void main() { printf("e :%f\n",e ); }#include<stdio.h> #define … Read more

Categories C

c preprocessor define

C #define: A macro value in C replaces a part of a program with a value already defined by #define directive. Syntax: #define macro_Name macro_Value Example: #include<stdio.h> #define PI 3.14 void main() { printf("PI :%f\n",PI ); printf("Date :%s\n", __DATE__ ); printf("Time :%s\n", __TIME__ ); printf("Line :%d\n", __LINE__ ); printf("STDC :%d\n", __STDC__ ); }#include<stdio.h> #define PI … Read more

Categories C

c preprocessor include

C# include: C #include is a preprocessor directive which is used in a C program to include the codes of a file into the current program file. There are two ways of using #include directive. #include <file_name> To check for the directory holding the required system header files, #include <file_name> is used. #include “file_name” To … Read more

Categories C