title: How to compile and run C program on Mac OS X
body: <p>I am learning C and wish to write the program using a text editor on my Mac (running <a href="https://en.wikipedia.org/wiki/OS_X_Lion" rel="nofollow noreferrer">OS X v10.7</a> (Lion)).</p>
  <p>I write the <code>.c</code> file, and compile it using <code>gcc filename.c</code> - which creates executable file called <code>a.out</code>. However, when I type <code>a.out</code> or <code>/a.out</code>, I get the following messages:</p>
  <blockquote>
  <p>-bash: a.out: command not found<code>or</code>-bash: /a.out: <br />
  No such file or directory</p>
  </blockquote>
  <p>I have successfully compiled and ran C programs on Linux systems before using this same method. What am I doing wrong on my Mac?</p>