Thread: One question about array and function prototype declaration

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    23

    Unhappy One question about array and function prototype declaration

    Hello all, do you think this below code will be compiled and work???
    I used VS 2005 and it did not work. but I haven't tried any other compiler yet!!.
    I will have to take exam about C programming. and the exam instruction says that I am not allowed to make change to any function signature!!

    Code:
    #include <stdio.h>
    
    int foo (int [] a);
    
    int main()
    {
         //... more code...
         return 0;
    }
    
    int foo (int[] a)
    {
    
    }

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Try putting the [] after the variable name.

    Edit: And return an int from your function.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    23
    Quote Originally Posted by MacGyver View Post
    Try putting the [] after the variable name.

    Edit: And return an int from your function.

    yeah, RIGHT!!!
    Code:
    int a[]
    is the correct form in C!

    However, I am asking them to clarify about that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  2. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  3. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM
  4. Help with an Array
    By omalleys in forum C Programming
    Replies: 1
    Last Post: 07-01-2002, 08:31 AM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM