title: Converting a #defined constant number to a string
body: <p>I have a constant defined:</p>
  
  <pre><code>#define MAX_STR_LEN 100
  </code></pre>
  
  <p>I am trying to do this:</p>
  
  <pre><code>scanf("%" MAX_STR_LEN "s", p_buf);
  </code></pre>
  
  <p>But of course that doesn't work.</p>
  
  <p>What preprocessor trick can be use to convert the MAX_STR_LEN numerica into a string so I can use it in the above scanf call ? Basically:</p>
  
  <pre><code>scanf("%" XYZ(MAX_STR_LEN) "s", p_buf);
  </code></pre>
  
  <p>What should XYZ() be ?</p>
  
  <p>Note: I can of course do "%100s" directly, but that defeats the purpose. I can also do #define MAX_STR_LEN_STR "100", but I am hoping for a more elegant solution.</p>