title: How to use scanf in a Swift environment
body: <p>I am practicing Objective C to get a better understanding of C and was using the newest Xcode, but using the terminal to write simple programs. In the the program below is can't seem to get the scanf function to work. Is there a different function that I can use to input data into the terminal to check the rest of syntax and coding?</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  int main (int argc, char *argv[])
  {
      int n, number, triangularNumber;
  
      NSLog (@"What triangular number do you want?");
  
      scanf ("%i", &amp;number);
  
      triangularNumber = 0;
  
      for ( n = 1; n &lt;= number; ++n )
          triangularNumber += n;
  
      NSLog (@"Triangular number %i is %i\n", number, triangularNumber);
  
      return 0;
  }
  </code></pre>