title: Stringify C preprocess
body: <p>This is my first post, so if I'm being too vague or giving information that everyone would intuitively assume, please let me know.</p>
  
  <p>I'm very new to writing in <strong>C</strong> and am just trying to get a better understanding of preprocessing.  I'm writing a simple program that can take in arguments either directly from the console using <code>gcc -Wall -std=c99 -DSEED=argument</code>, where my argument should be a an integer, or if the <code>-D</code> is not defined the user will input it.</p>
  
  <p>The SEED value is simply used in <code>srand()</code>.  I'm very confused why my code will not compile if I put in an <code>-DSEED=a</code> as my argument while if I put <code>-DSEED=1</code> it will compile.  I'm getting a "âaâ undeclared (first use in this function)" error and really don't understand the difference between the two.  I thought the <code>#define</code> matched up the variable type with the input, so if I put in an "a" #SEED would be a char and if I put in a "1" #SEED would be an int.</p>
  
  <p>If the SEED is not defined I'm using a <code>#ifndef SEED</code> command and this works well.
  I think I'm supposed to "stringify" the input <code>SEED</code> and then can check if it is an integer or not.  After reading some articles online I'm trying to use:</p>
  
  <pre><code>#ifndef SEED
      //code
  #else
      #define TO_STRING( input ) #input
      char c;
      c = TO_STRING( SEED )
      //Then I was going to use c to figure out if it was an int.
  #endif
  </code></pre>
  
  <p>This is not working and anyone able to point out any misconceptions that you think that I may have would be greatly appreciated.  </p>
  
  <p>EDIT - So I did figure out why I was receiving the error message when trying the <code>-DSEED=a</code>, because it was reading it as a variable.</p>