title: C preprocessor macro for returning a string repeated a certain number of times
body: <p>Does someone know of any C99 preprocessor magic that allows for creating a string consisting of another string repeated N times?</p>
  
  <p>E.g.</p>
  
  <pre><code>STRREP( "%s ", 3 )
  </code></pre>
  
  <p>becomes</p>
  
  <pre><code>"%s %s %s "
  </code></pre>
  
  <p>after preprocessing.</p>
  
  <p>The only thing I could think of myself was something like this</p>
  
  <pre><code>#define STRREP( str, N ) STRREP_##N( str )    
  #define STRREP_0(str) ""
  #define STRREP_1(str) str
  #define STRREP_2(str) str str
  #define STRREP_3(str) str str str
  ...
  </code></pre>
  
  <p>which works well, but is ugly as I have to define a macro for each repetition length manually. I want to use it together with variadic macros and the macro returning the number of macro arguments shown <a href="https://stackoverflow.com/questions/2308243/macro-returning-the-number-of-arguments-it-is-given-in-c">here</a>.</p>