Thread: what does"..." prototype in C mean?

  1. #1
    Registered User
    Join Date
    Sep 2005

    Cool what does"..." prototype in C mean?

    Please help,

    I am a beginner in C programming and people have been asking this question to me in many of the interviews.

    Please tell me
    what does"..." prototype in C mean?


  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    It represents a variable number of arguments. It's why we can do things like this:
    printf("Hello World!\n");
    printf("%d + %d = %d", 1, 2, 1 + 2 );
    In the first, the function takes one argument. In the second, it has four.

    Hope is the first step on the road to disappointment.

  3. #3
    Gawking at stupidity
    Join Date
    Jul 2004
    Oregon, USA
    itsme@itsme:~/C$ cat varargs.c
    #include <stdio.h>
    #include <stdarg.h>
    void sum(int nargs, ...)
      va_list ap;
      int i, sum;
      va_start(ap, nargs);
      for(i = sum = 0; i < nargs;++i)
        sum += va_arg(ap, int);
      printf("Received %d ints whose sum is %d.\n", nargs, sum);
    int main(void)
      sum(1, 86);
      sum(3, 4, 5, 6);
      return 0;
    itsme@itsme:~/C$ ./varargs
    Received 1 ints whose sum is 86.
    Received 3 ints whose sum is 15.
    If you understand what you're doing, you're not learning anything.

  4. #4
    Registered User
    Join Date
    Sep 2005

    what is a prototype?

    hEY THERE,
    When you write your program, and you have a function inside specify in the beginning of the program that you will be having a function later on that would contain certain number of arguments and also would be returning some type:The compiler would not be confused then when it encountered your function, but if you don't have a prototype, you'd throw your compiler into a state of "entropy" if i may borrow the word..
    Look at my representation below "not real program"

    #include <stdio.h>
    int  my_name_is_proto(int a, int b);
    int well_im_different( double p, double j);
    // note the semicolon at the end of the prototype..not present in the function declaration itself....
    int main ()
       int  ans, ans2, i;
       ans= ans2 = 0;
        ----                     //your codes in here
       ans = my_name_is_proto(6, 7);// you invoke the funtion here,  
       ans2 = well_im_different(5.22, 2.33);
      return (0);
     int my_name_is_proto(int a, int b)
      ------ //process the function in here
     int well_im_different(double p , double j)
           --------//process your funtion in here
    I Hope you get the general idea of the prototype..but i'm sure any c text would give you full details and examples..

    Take it easy nd goodluck...

  5. #5
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Sydney, Australia

    You didn't answer the original question, and 2 other posters already did answer 6 hours earlier.

  6. #6
    Registered User
    Join Date
    Sep 2005

    Smile thankyou

    thanks a lot guys for ur answer to "...". I appreciate your help


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 08-24-2006, 01:22 AM
  2. Function prototype questions
    By Kayoss in forum C++ Programming
    Replies: 6
    Last Post: 11-30-2005, 05:27 PM
  3. prototype poblem
    By bazzano in forum C Programming
    Replies: 3
    Last Post: 10-30-2005, 10:01 AM
  4. Prototype syntax for sub-class constructor
    By starkhorn in forum C++ Programming
    Replies: 1
    Last Post: 10-08-2004, 08:33 AM
  5. call to function without prototype
    By lgbeeb in forum C Programming
    Replies: 2
    Last Post: 03-25-2003, 12:20 PM
Website Security Test