Tuesday, 9 December 2014

C program without main with 2 functions

program without main with 2 functions
#include<stdio.h>
#include<stdlib.h>
vector()
{
printf("function with   main....\n");
f1();
f2();
printf("we are in main function\n");
exit(0);
}
f1()
{
printf("we are in f1 function\n");
}
f2()
{
printf("we are in f2 function\n");
}
OutPut:
madan@madan-Lenovo-G570:~/madan$ vi with2fun.c
madan@madan-Lenovo-G570:~/madan$ cc -nostartfiles with2fun.c
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000400390
madan@madan-Lenovo-G570:~/madan$ ./a.out
function with   main....
we are in f1 function
we are in f2 function
we are in main function