Thread: fuction calls

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    41

    Exclamation fuction calls

    Can someone give me an example of how to call a function? I have o write a program and I need to call a function but I'm totally clueless onhow to do that.

    Thanks.

    Jessica

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    1) Define or prototype the function.
    2) Use it in a function elsewhere.

    Examples:

    Code:
    int function( void ); /* A function prototype. */
    
    int main( void )
    {
        function( ); /* Call the function. */
    }
    
    int function( void ) /* Define the function. */
    {
        printf("Function called.\n");
        return 0;
    }
    Or, without a prototype:

    Code:
    int function( void ) /* Define the function. */
    {
        printf("Function called.\n");
        return 0;
    }
    
    int main( void )
    {
        function( ); /* Call the function. */
    }
    In the second example, I don't need a prototype because I have defined the entire function before I ever call it. In the first example, 'main' wouldn't have been aware of the function if I didn't prototype it first, because it was declared after main tried to use it.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. How do you make calls?
    By scatterice in forum C Programming
    Replies: 1
    Last Post: 03-09-2009, 06:07 PM
  3. Need some help,,system calls
    By kodiak76 in forum Linux Programming
    Replies: 6
    Last Post: 01-25-2005, 12:25 PM
  4. Which I/O calls do you use the most?
    By _Elixia_ in forum Tech Board
    Replies: 10
    Last Post: 07-11-2003, 11:58 AM
  5. C/C++ Memory Calls!
    By Joda in forum C++ Programming
    Replies: 7
    Last Post: 10-25-2002, 04:50 PM