title: Checking contents of char variable - C Programming
body: <p>This might seem like a very simple question, but I am struggling with it.  I have been writing iPhone apps with Objective C for a few months now, but decided to learn C Programming to give myself a better grounding.</p>
  
  <p>In Objective-C if I had a UILabel called 'label1' which contained some text, and I wanted to run some instructions based on that text then it might be something like;</p>
  
  <pre><code>if (label1.text == @"Hello, World!")
  {
  NSLog(@"This statement is true");
  }
  else {
  NSLog(@"Uh Oh, an error has occurred");
  }
  </code></pre>
  
  <p>I have written a VERY simple C Program I have written which uses <code>printf()</code> to ask for some input then uses <code>scanf()</code> to accept some input from the user, so something like this;</p>
  
  <pre><code>int main()
  {
      char[3] decision;
  
      Printf("Hi, welcome to the introduction program.  Are you ready to answer some questions? (Answer yes or no)");
      scanf("%s", &amp;decision);
  }
  </code></pre>
  
  <p>What I wanted to do is apply an <code>if</code> statement to say if the user entered yes then continue with more questions, else print out a line of text saying thanks.</p>
  
  <p>After using the scanf() function I am capturing the users input and assigning it to the variable 'decision' so that should now equal yes or no.  So I assumed I could do something like this;</p>
  
  <pre><code>if (decision == yes)
  {
       printf("Ok, let's continue with the questions");
  }
  else 
  {
       printf("Ok, thank you for your time.  Have a nice day.");
  }
  </code></pre>
  
  <p>That brings up an error of "use of undeclared identifier yes".  I have also tried;</p>
  
  <pre><code>if (decision == "yes")
  </code></pre>
  
  <p>Which brings up "result of comparison against a string literal is unspecified"</p>
  
  <p>I have tried seeing if it works by counting the number of characters so have put;</p>
  
  <pre><code>if (decision &gt; 3)
  </code></pre>
  
  <p>But get "Ordered comparison between pointer and integer 'Char and int'"</p>
  
  <p>And I have also tried this to check the size of the variable, if it is greater than 2 characters it must be a yes;</p>
  
  <pre><code>if (sizeof (decision &gt; 2))
  </code></pre>
  
  <p>I appreciate this is probably something simple or trivial I am overlooking but any help would be great, thanks.</p>