Thread: Function Prototype & header file

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    2

    Smile Function Prototype & header file

    hi

    I am beginner to C. I want to know the answers for the following questions...


    1. Is it necessary to declare function prototype?

    2. What actually the C header files contains - declarations or definitions?

    3. What does it mean 'Error: Code has no effect'.......what to do?

    please reply....

    thanks & regards
    Sarwan

  2. #2
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    1. Is it necessary to declare function prototype?
    Not really if you have the function definition, before the function is called. If not you need one

    2. What actually the C header files contains - declarations or definitions?
    Header file contains the declaration, perhaps you can open one and see then by u'rself

    3. What does it mean 'Error: Code has no effect'.......what to do?
    There are many reasons, It would be more help full if could show use the code.

    ssharish2005

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    2

    Header File

    hi...first thanks for replies....

    I asked 3 questions....in that I am got cleared for 2 questions.....still i have doubt in 1 question...

    1. What actually the C header files contains - declarations or definitions?

    for the above questions...one of our friend replied 'C header files contains declarations' and also he told me to open and see one header file...

    As per his advice I opened 'STDIO.H' file..... I can able to see all declarations, but.... in that header file.....the first comment says as follows...


    /* stdio.h

    Definitions for stream input/output.

    Copyright (c) 1987, 1991 by Borland International
    All Rights Reserved.
    */


    *****what does the bold lines says?.......by seeing that line....i got doubt...What actually the C header files contains declarations or definitions?

    please reply

    thanks & regards
    Sarwan

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Quote Originally Posted by sarwansan View Post
    1. Is it necessary to declare function prototype?
    In C99, I believe you must. In C89, not always.

    Therefore, always use a function prototype.

    Quote Originally Posted by sarwansan View Post
    2. What actually the C header files contains - declarations or definitions?
    The C standard header files are special. The compiler knows how to find the implementations. Just be happy to include the headers.

    For your own purposes, only put declarations and function prototypes inside your header files. Don't actually write out a function implementation inside a header file.

    Quote Originally Posted by sarwansan View Post
    3. What does it mean 'Error: Code has no effect'.......what to do?
    You wrote a statement that does nothing.

    For example:

    Code:
    x < 5;
    The above statement doesn't do anything important. It doesn't alter memory, and it doesn't cause a branch in execution. Such a statement should be altered, or removed, depending upon the intent.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  3. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  4. Header file for "fix" function ?
    By Rex in forum C++ Programming
    Replies: 1
    Last Post: 04-08-2003, 04:42 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM