CoolInterview.com - World's Largest Collection of Interview Questions
 Interview Questions  
 Our Services  

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!


    Send your Resume to 6000 Companies


  • INTERVIEW QUESTIONS LANGUAGES C DETAILS
    Question :
    Is it acceptable to declare/define a variable in a C header?
    Category C Interview Questions
    Rating (3.5) By 4 users
    Added on 10/22/2004
    Views 3504
    Rate it!
    Answers:

    A global variable that must be accessed from more than one file can and should be declared in a header file. In addition, such a variable must be defined in one source file.

    Variables should not be defined in header files, because the header file can be included in multiple source files, which would cause multiple definitions of the variable. The ANSI C standard will allow multiple external definitions, provided that there is only one initialization. But because there?s really no advantage to using this feature, it?s probably best to avoid it and maintain a higher level of portability.

    ?Global? variables that do not have to be accessed from more than one file should be declared static and
    should not appear in a header file.





    If you have the better answer, then send it to us. We will display your answer after the approval.
    Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

       
    Related Questions
    View Answer
    What is the difference between declaring a variable and defining a variable?
    View Answer
    Can static variables be declared in a header file?
    View Answer
    What is the benefit of using const for declaring constants?
    View Answer
    What is the easiest sorting method to use?
    View Answer
    What is the quickest sorting method to use?
    View Answer
    How can I sort things that are too large to bring into memory?
    View Answer
    What is the easiest searching method to use?
    View Answer
    What is the quickest searching method to use?
    View Answer
    What is hashing?
    View Answer
    How can I sort a linked list?
    View Answer

    Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

    Notify me when better answer is posted!
    Email:

    View ALL C Interview Questions

    User Options
    Sponsored Links


    Copyright ©2003-2009 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions
    Page URL: http://www.coolinterview.com/interview/1052/default.asp?cachecommand=bypass


    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | Joke of the Day

    0.41