A main program without main :)
Page 1 of 1 • Share •
A main program without main :)
Here goes the challenge to all..........
Write a C program without the function main()...........

Write a C program without the function main()...........
Invincible- Posts: 2
Join date: 2008-08-10
Re: A main program without main :)
#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("Hello World!");
return 0;
}
#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("Hello World!");
return 0;
}
Beagle- Posts: 9
Join date: 2008-08-12
Re: A main program without main :)
you have done dis through macros ultimately u r using main question is not that
wat u have to do is not to use main u have to use your startup function ........
wat u have to do is not to use main u have to use your startup function ........
Admin- Admin
- Posts: 39
Join date: 2008-08-03

Re: A main program without main :)
#include<stdio.h>
#include <unistd.h>
_start()
{
_exit(my_main());
}
int my_main(void)
{
printf("Hello\n");
return 42;
}
compile with
gcc -O3 -nostartfiles test.c
#include <unistd.h>
_start()
{
_exit(my_main());
}
int my_main(void)
{
printf("Hello\n");
return 42;
}
compile with
gcc -O3 -nostartfiles test.c
arahan- Posts: 4
Join date: 2008-10-14
Permissions of this forum:
You cannot reply to topics in this forum





