Re: How to execute the user defined ...

sumit kumar <sumit_india1998-/[email protected]> Wed, 28 Dec 2005 02:12:45 -0800 (PST)
Newsgroups gmane.comp.lang.c.general,gmane.comp.programming.cppug
Message-ID <[email protected]>
  At 05:54 2005-12-27, Jitendra Kumar wrote:
>Hi all to the members of wonderful forum,
>
>Y'day i had an interview, this was the qstn:
>
>Write a program which will execute before the main
>function, dont use #pragma or compiler level programs?

what language?  If C++, trivial:   write a struct 
or class with your program in the constructor.
define an instance as a global variable.

in C?  I have no idea.


>Pls post the answer.
>Thanku,
>
>Jitendra
Maneesh Anand Samria <anand_at_maiet-/[email protected]> wrote:
    Lets try this 
  #include<stdio.h>
int before()
{
 printf("HELLO");
 return 1;
}
int i = before();
void main()
{
 printf("main");
}

    This wont work since initialiser must be a constant. 
   
  Regards,
  Sumit kumar


		
---------------------------------
Yahoo! for Good - Make a difference this year.