"Terminal" is an application that emulates a terminal with characteristics similar to a DEC VT-220 terminal with a variable screen size. It is incapable of executing commands, (including compiling any type of source code). OS X runs some command (usually a shell such as bash, csh, ksh, sh [a version of bash on OS X], tcsh, or zsh) and that command running in terminal may be able to execute commands.
I have never seen a shell with a built-in C language compiler either, although in theory that is possible.
So, to compile a C program, in addition to terminal and a shell, you need a compiler. OS X out of the box doesn't contain a compiler, but you can download the Xcode package from the app store which will give you some compilers (including cc, gcc, c++), the tools you need to turn a compiled program into an executable object, utilities like lex, make, and yacc), and graphical tools to build OS X and iOS applications to run on Macs, iPads, iPhones, iWatches, and other devices. So, download and install Xcode.
Then (assuming your source code is in a file named calc.c), you can compile your code into an executable file named calc with either of the following commands typed into the shell you have running in terminal:
But, I wouldn't consider this code to be a good example of C coding, and would be very surprised if it produced the output you might expect:
it is missing several headers that are needed to define function prototypes,
it calls printf() without a format string operand seemingly assuming that it will magically use an integer argument passed in as a pointer to a format string to print the value of that integer,
it uses the system() function to invoke a command that is not available on OS X systems (for no apparent reason),
(if you have written and installed a command named pause and it exits), waits for the user to type in another character for no apparent reason,
and then (if the character typed was "q" or any other character), exits.
I hope this helps...
This User Gave Thanks to Don Cragun For This Post:
Hey everyone
I'm new to UNIX due to the new Mac OS X operating system and would like some help. I'm trying to send an email via the UNIX-Shell-Terminal i Mac OS X, (it's called darwin)
How do I do that? When I enter the Command mail I can send messages to root and with the command -forward... (4 Replies)
I would like to start coding on my mac, but I'm getting an error when I attempt to execute my script
-bash : testscript: command not found
I have verified that the #! line points to the correct directory.
If you have some insight it would be greatly appreciated!
- D (1 Reply)
Hey all..
I have a problem with the BitTorrent client called Deluge. (Deluge BitTorrent Client). Followed the guide on their homepage, but can't get it to work.
First of all I have installed Xcode Tools 3.0 and MacPorts. I did the "sudo port install deluge" command, and all packages seemed to... (1 Reply)
Hi,
What command is needed to find all or certain users from a terminal window in MAC OS X 10.5?
Where is a list of categorized commands that could help me find answers similar to this particular question?
Thanks.
Juan Dent (1 Reply)
Hi everyone. I'm new to using the Terminal and was just wondering if anyone had a link to perhaps a list of commands. And tips on some useful websites to visit or books to read.
Oh and is there a way to delete just part of the Terminal's history? If so what is the command?
Thanks :) (2 Replies)
I finally got how to su - in my mac from the terminal. Now I would like to be able to add new users. useradd -m -d ..... doesn't seem to work. (1 Reply)
Hi,
I am new for SVN. Earlier I have been using CVS. When I checkout the code from SVN using Eclipse, the size of the source code checked out is 612MB. But when I try to checkout from terminal, from my 5.8 branch , the checked out source code's size is only 312.1 MB.
Can anyone tell me... (0 Replies)
Is there a trick to closing a mac terminal with a command? I would think you could just type exit into your terminal but that doesn't work. I also tried quit and close just for the hell of it and that didn't work either. Does anyone know what the command is? (1 Reply)
Does anyone know the differences in commands when it come to Linux and Mac OS X? I'm wanting to know if I use "this" command in Linux and It doesn't work in Mac then what command is equivalent to the one in Linux. Example Ctrl+Alt+f2 switches to (tty2) so what equivalent switches to ttys2 on Mac? (13 Replies)