Results 1 to 4 of 4

Thread: Problem to call a function

  1. #1
    Join Date
    Mar 2008
    Posts
    672

    Problem to call a function

    My programs gives an error : syntax error before ']' for line 11? I also wanted to know how to call a function in c program?
    Code:
    # include <stdio.h> 
     # include <stdlib.h> 
    
    int (sum_table int array [], int height); 
    
      int main (int ar, char * agv []) 
      ( 
      int array [5] = (1, 2, 3, 4, 5); 
    
      printf ( "Here is the sum of the table:% d", sum_table (array [], 5)); 
    
          return 0; 
      ) 
    
      sum_table int (int array [], int size) 
      ( 
          int i, sum; 
    
          for (i = 0; i <size; i + +) 
          ( 
              sum = sum + array [i]; 
          ) 
    
          return sum; 
      )

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Problem to call a function

    A function is a group of statements like int main and sum_table int mai in you r case that is executed when it is called from some point of the program. The following is its format: type name ( parameter1, parameter2, ...) { statements }

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: Problem to call a function

    the call to "sum_table" is not good. Remove the brackets after the table (in the function parameters sum_table) in the function call only. Initialize "sum" in function.

    Code:
    	  sum = 0;

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: Problem to call a function

    A function call is an expression that passes control and arguments (if any) to a function and has the form
    Code:
     expression ( expression-list <SUB>opt</SUB> )
    where expression is a function name or evaluates to a function address and expression-list is a list of expressions (separated by commas). The values of these latter expressions are the arguments passed to the function. If the function does not return a value, then you declare it to be a function that returns void.

Similar Threads

  1. How to call a function in the "main" function
    By MaryJ in forum Software Development
    Replies: 1
    Last Post: 19-11-2010, 01:40 AM
  2. Call a function depending on the variable name
    By Captain Carrot in forum Software Development
    Replies: 5
    Last Post: 23-03-2010, 09:27 AM
  3. Pure virtual function call
    By Heather5 in forum Software Development
    Replies: 4
    Last Post: 21-10-2009, 10:54 PM
  4. Making a function call to C++ or CLI DLL from VB.Net?
    By Ettan in forum Software Development
    Replies: 3
    Last Post: 31-03-2009, 02:05 AM
  5. PLEASE HELP!!! Error DLL Function call crashed
    By nhet in forum Windows XP Support
    Replies: 2
    Last Post: 13-10-2008, 01:33 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,138,311.47425 seconds with 16 queries