Strange parameter list in function

This is a discussion on Strange parameter list in function within the C++ Programming forums, part of the General Programming Boards category; What does ... mean in a fuction parameter list like Code: void test(int temp2, ...);...

  1. #1
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343

    Strange parameter list in function

    What does ... mean in a fuction parameter list like

    Code:
    void test(int temp2, ...);

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    You can also take advantage of this in your own functions thanks to stdarg.h (or <cstdarg> as it is in c++)

    Code:
    #include <iostream>
    #include <cstdarg>
    using namespace std;
    
    
    void ToScreen(int nNoArg,...){
    
    	va_list args;//list of arguments
    	
    	va_start(args,nNoArg);//start point
    	
    	for(int i = 0;i < nNoArg;++i)//print each
    		cout << va_arg(args,int) << endl;
    		
    	va_end(args);//end
    
    }
    	
    
    
    int main(){
    	
    	//first arg says how many args to follow
    	ToScreen(4,1,2,3,4);
    	
    }

  3. #3
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    k, se you point here.

    Have you ever used printf() at all (in stdio.h)?
    Almost nothing. Ive one of thoose who started with c++ before c and Im always using the cout object.

    Is this the only way you use ... or there other combinations?? E.i like

    Code:
    void tmp(...);
    Ive tried t obtain more information about this but I dont really know how to search it .

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  3. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  4. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  5. Reverse function for linked list
    By Brigs76 in forum C++ Programming
    Replies: 1
    Last Post: 10-25-2006, 10:01 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21