Its again me only.... no only i am learning variadic functions topic and as soon as i completed i thought to write a example function . but i got stuck up!....
See i wants to write a variadic function called xstrcpy() in which the minimum number of arguments should be 2 and max is virtually the maximum number the c compiler supports. but i don't want a parameter to specify how many arguments that i am going to pass at the time of function call...
So is there any mechanism in c/c++ to find the number of arguments that is supplied to the called function?
Here is my code for xstrcpy()
Expand|Select|Wrap|Line Numbers
- void xxstrcpy(short temp,char *dest,const char *src,...)
- {
- va_list strings;
- xstrcpy(dest,src);
- va_start( strings, src) ;
- while ( temp-- )
- {
- xstrcat(dest, va_arg ( strings, char * )) ;
- }
- va_end ( strings ) ;
- }
- int main()
- {
- char sstring[255];
- xxstrcpy(3,sstring,"hello ","welcome "," wih u the best"," bad programmer");
- printf("%s", sstring);
- getch();
- return 0;
- }
So i wanna to get rid of the argument1 which specifies how many strings i am going to pass for the function to perform strcat() operation.
So plese help me on this!.......