Is it possible to run a c program without using main?If yes
HOW??

Answers were Sorted based on User's Feedback



Is it possible to run a c program without using main?If yes HOW??..

Answer / elahi

Yes it is possible to run a c program with out main for this
you need to supply astart(assembly procedure CRT) address in
the command line.

Is This Answer Correct ?    41 Yes 7 No

Is it possible to run a c program without using main?If yes HOW??..

Answer / rajiv kumar koiri

#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");
}

Is This Answer Correct ?    16 Yes 3 No

Is it possible to run a c program without using main?If yes HOW??..

Answer / adesh

#define adesh(x,y) y##x

int adesh(in,ma) (void)
{
;
}

Is This Answer Correct ?    13 Yes 3 No

Is it possible to run a c program without using main?If yes HOW??..

Answer / vrushali

Hi Valli,

I tried the solution provided by you. It doesnot work.

Please chk the compliation procedure.
gcc -g -nostartfiles main.c


I am getting the following:
/usr/bin/ld: warning: cannot find entry symbol _start;
defaulting to 080481a4

Is This Answer Correct ?    9 Yes 1 No

Is it possible to run a c program without using main?If yes HOW??..

Answer / valli

just compile as
cc -nostartfiles main.c

Is This Answer Correct ?    6 Yes 2 No

Is it possible to run a c program without using main?If yes HOW??..

Answer / sourisengupta

Thanx elahi....

Is This Answer Correct ?    8 Yes 5 No

Is it possible to run a c program without using main?If yes HOW??..

Answer / ramabrahmam

hi adesh,
your logic is not suited to numbers.
suppose, if we write "printf" as
for two integers a,b
printf("sum of a and b is",a+b);
for this statement it only displaying the letters
within the double quotes.i.e., sum of a and b is .
it is not displaying anything after that.

Is This Answer Correct ?    1 Yes 0 No

Is it possible to run a c program without using main?If yes HOW??..

Answer / bhavin

hi friends plz help me i want detail how can it
possible...??plz friend,,,also to adesh,valli,elahi...all

Is This Answer Correct ?    3 Yes 3 No

Is it possible to run a c program without using main?If yes HOW??..

Answer / vrushali

HI Valli,

Still the same problem.

/usr/bin/ld: warning: cannot find entry symbol _start;
defaulting to 080481a4

Is This Answer Correct ?    2 Yes 4 No

Is it possible to run a c program without using main?If yes HOW??..

Answer / ankith.v

It is not possible

Is This Answer Correct ?    3 Yes 6 No

Post New Answer

More C Interview Questions

Why is it usually a bad idea to use gets()? Suggest a workaround.

1 Answers  


What is the output of below code? main() { static in a=5; printf("%3d",a--); if(a) main(); }

4 Answers   Infosys, TCS,


What is difference between union and structure in c?

0 Answers  


Write a program to generate the first n terms in the series --- 2,3,5,7,11,...,17

0 Answers  


can we access one file to one directory?

1 Answers  






main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }

11 Answers   HCL, Vector, Vector India, Vector Solutions, Wipro,


20. main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); } Answer:??????

2 Answers  


A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(

0 Answers  


Explain what is the difference between functions getch() and getche()?

0 Answers  


what is ram?

3 Answers   TCS,


how should functions be apportioned among source files?

0 Answers  


How to calculate sum

2 Answers  


Categories