Re: Re: [c-prog] How to execute the user defined ...

sumit kumar <[email protected]> Fri, 30 Dec 2005 07:57:55 -0800 (PST)
Newsgroups gmane.comp.programming.cppug
Message-ID <[email protected]>
reply inline...
Shiju Krishnan <[email protected]> wrote:    >#include<stdio.h>
>int before()
>{
>    printf("HELLO\n");
>    return 1;
>}
>int i = before();
>int main()
>{
>    printf("main\n");
>    return 0;
>}

>this work out on solaris 

  That must be because of some bug on solaris C compiler you are using since GCC an VC report error ::: error C2099: initializer is not a constant

  Regards,
  Sumit Kumar
  +91-80-30956948
>Regards 
>Shiju K.


  On 12/28/05, sumit kumar <[email protected]> wrote:      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 < [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. 
    
---------------------------------
  YAHOO! GROUPS LINKS 

    
    Visit your group "cppug" on the web.
   
    To unsubscribe from this group, send an email to:
  [email protected]
   
    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service .

    
---------------------------------
  
  



    
---------------------------------
  YAHOO! GROUPS LINKS 

    
    Visit your group "cppug" on the web.
    
    To unsubscribe from this group, send an email to:
 [email protected]
    
    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 

    
---------------------------------
  




		
---------------------------------
Yahoo! Shopping
 Find Great Deals on Holiday Gifts at Yahoo! Shopping