va_list or operator overloading in the case of adding strings.

1
2
3
4
5
6
7
8
9
10
11
12
13
void incr(unsigned short x,...){
 va_list arguments;
  register unsigned char *cur_arg;
   va_start(arguments,x);
    do{
     cur_arg=va_arg(arguments,unsigned char*);
      for(register unsigned y = 0;cur_arg[y]!='\0';++y,++cam){
       if (cam+1>=tam) alloc();
       p [cam] = cur_arg[y];
     }
    }while(--x);
 va_end(arguments);
};


incr() performs what a string::operator+=() does, only processing all the arguments at once.

My question is, would it be faster to use a va_list in the case of adding
strings, instead of an overloaded operator?

With an overloaded operator you would need to enter, re-enter functions all the time, would it be better to just keep the process inside one function, but with the downside of using a va_list?

EDIT: I am quite ignorant as to 'how' a va_list works, i only know how to use it.
Last edited on
Topic archived. No new replies allowed.