This is a C program to display function without using the main function.
This program displays function without using the main function.
1. Use #define macro to rename the main.
2. Print the output and exit.
Here is source code of the C Program to display function without using the main function. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
/*
* C Program to display function without using the Main Function
*/
#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(" helloworld ");
}
1. Use #define macro for doing this.
2. #define decode(s,t,u,m,p,e,d) m##s##u##t.
This code says, next time when decode is encountered with 7 parameters, replace it by the concatenation of the 4th,1st,3rd and 2nd argument.
3. #define begin decode(a,n,i,m,a,t,e). In this line the 4th, 1st, 3rd and 2nd argument are m, a, i and n respectively. So the main is replaced by begin.
4. Use function named begin and print the output as ” helloworld ” and exit.
Output: helloworld
Sanfoundry Global Education & Learning Series – 1000 C Programs.
Here’s the list of Best Books in C Programming, Data-Structures and Algorithms
- Get Free Certificate of Merit in C Programming
- Participate in C Programming Certification Contest
- Become a Top Ranker in C Programming
- Take C Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Buy Computer Science Books
- Apply for C Internship
- Buy C Books
- Practice BCA MCQs
- Apply for Computer Science Internship