C program without using main function

Write a C program without using main function.
In this program, we didn’t use the main function, but we are using the preprocessor directive #define with arguments to define the Main function.
A Preprocessor is program which processes the source code before compilation.
The ‘##‘ operator is called the token pasting or token merging operator. In the second line of program we used it to merges the 4th,1st,3rd & the 2nd characters(tokens), and it compiles as “msut”.
When the controller calls int begin, preprocessor replaces the macro “begin” with the expansion decode(a,n,i,m,a,t,e). As defined in the macro decode it merges the 4th,1st,3rd & the 2nd characters, and int begin becomes int main(), so program runs successfully. Read more about C Programming Language . and read the C Programming Language (2nd Edition). by K and R.
–>

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include<stdio.h>
#define decode(s,t,u,m,p,e,d) m##s##u##t
#define begin decode(a,n,i,m,a,t,e)

int begin()

{
printf(” Ha HA see how it is?? “);
}
Read more Similar C Programs

Graphics in C

C Strings
C Aptitude 

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

–> To browse more C Programs visit this link
(c) www.c-program-example.com

C Program to Demonstrate #if, #else & #endif preprocessors.

C Program to demonstrate the Preprocessor directives like #if, #else, #define, #endif. C Preprocessors are not the program statements, they are executed before the actual compilation of the code. C Preprocessors substitute the code where they called, i.e they replace the code as they defined. #if, #else are the conditional directives. Here at the compile time #if value is false, so #else part is execute.
Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include<stdio.h>

#define SWITCH 0

/* The #if can only perform
* INTEGER tests!!!!
*/
#if ( SWITCH == 1 )
#define TEXT "Example to #if"
#else
#define TEXT "Example to # else"
#endif

main ()
{
printf(TEXT);
}
Read more Similar C Programs
Learn C Programming

Number System

Preprocessor
You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C program to Demonstrate the #define pre-processor.

C Program to demonstrate #define pre-processor. Macro is a piece of text that is expanded by the pre-processor part of the compiler. This is used in to expand text before compiling. Macro definitions (#define), and conditional inclusion (#if). In many C implementations, it is a separate program invoked by the compiler as the first part of translation.Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/


#define EQ ==

main ()
{
/* the EQ is translated to == by
* the C pre-processor. COOL!
*/
if ( 5 EQ 5 ) printf("define works...n");
}
Read more Similar C Programs
Learn C Programming

Number System

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com