title: How to create one function to serve any number of arguments in C++?
body: <p>I am using a class to call the void for an array of options.  this void looks like the below code, and I am trying to create a definition for charf that could serve any number of arguments.  If you look at the code below, you will see why I would need it to serve ANY number of arguments.</p>
  
  <pre><code>void Player::drawOptions()
  {
      u32 _q;
      const char *buffer;
      char *_1 = optBuf[0], *_2 = optBuf[1], *_3 = optBuf[2], *_4 = optBuf[3], *_5 =     optBuf[4], *_6 = optBuf[5], *_7 = optBuf[6], *_8 = optBuf[7], *_9 = optBuf[8], *_10 =     optBuf[9], *_11 = optBuf[10], *_12 = optBuf[11], *_13 = optBuf[12], *_14 = optBuf[13], *_15     = optBuf[14], *_16 = optBuf[15], *_17 = optBuf[16], *_18 = optBuf[17];
      for(_q = 0; _q&lt;17; _q++)
      switch(_q)
      {
      case 1:buffer = charf("&amp;s", _1);break;
          case 2:buffer = charf("%s\n%s", _1, _2);break;
          case 3:buffer = charf("%s\n%s\n%s", _1, _2, _3);break;
          case 4:buffer = charf("%s\n%s\n%s\n%s", _1, _2, _3, _4);break;
          case 5:buffer = charf("%s\n%s\n%s\n%s\n%s", _1, _2, _3, _4, _5);break;
          case 6:buffer = charf("%s\n%s\n%s\n%s\n%s\n%s", _1, _2, _3, _4, _5,     _6);break;
          case 7:buffer = charf("%s\n%s\n%s\n%s\n%s\n%s\n%s", _1, _2, _3, _4, _5, _6,     _7);break;
          case 8:buffer = charf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", _1, _2, _3, _4, _5,     _6, _7, _8);break;
          case 9:buffer = charf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", _1, _2, _3, _4,     _5, _6, _7, _8, _9);break;
          case 10:buffer = charf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", _1, _2,     _3, _4, _5, _6, _7, _8, _9, _10);break;
          case 11:buffer = charf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", _1,     _2, _3, _4, _5, _6, _7, _8, _9, _10, _11);break;
          case 12:buffer = charf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s",     _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12);break;
          case 13:buffer =     charf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", _1, _2, _3, _4, _5, _6, _7, _8,     _9, _10, _11, _12, _13);break;
          case 14:buffer =     charf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", _1, _2, _3, _4, _5, _6, _7,     _8, _9, _10, _11, _12, _13, _14);break;
          case 15:buffer =     charf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", _1, _2, _3, _4, _5, _6,     _7, _8, _9, _10, _11, _12, _13, _14, _15);break;
          case 16:buffer =     charf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", _1, _2, _3, _4, _5,     _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16);break;
          case 17:buffer =     charf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", _1, _2, _3, _4,     _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17);break;
          case 18:buffer =     charf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", _1, _2, _3,     _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18);break;
      }
      menu.max = option;
      _q = 0;
      elems[OPTIONS]-&gt;elem.text = LocalizedString(buffer),
      clearOptions();
  }
  </code></pre>
  
  <p>I know this is poorly formatted, but I pasted where it said type code here, and it still did this.  Anyways, I know I would need to use something like:</p>
  
  <pre><code>const char* charf(const char* optName, const char* optNum)
  </code></pre>
  
  <p>But how would I make it so the optNum is used for anything from 1 to 18 arguments?</p>