title: How to declare a variable in the brackets of if statement?
body: <p>I want to declare a local variable in the brackets of an if statement.
  For example.</p>
  
  <pre><code>if((char c = getc(stdin)) == 0x01)//This is not OK with g++.
  {
      ungetc(c, stdin);
  }
  </code></pre>
  
  <p>What I want is, to see if the character is the one I want.
  To say it commonly, I want to use the variable(char c) both in the line of <em>if</em> and the body of <em>if</em>, but not outside the <em>if</em>.</p>
  
  <p>But g++(GCC 4.8.1) says <em>expected primary-expression before 'char'</em>.
  I wonder if there's a way to do that, because I don't want something like</p>
  
  <pre><code>char c = getc(stdin);
  if(c == 0x01)
  {
      bla...
  }
  </code></pre>