how to write c codes in UNIX

Sorry for asking a very basic question.

How do i compile my c codes in UNIX.

That is how do i know whether any c compiler is there in my system?

If nothing is present where from do i get one and load into my system?

Check if your UNIX can execute "cc". This should be a link to the C compiler. If none is present, you might want to get a gcc package for your UNIX.

first save your program with .c extension then,
enter the command

                 cc <file name> 

Unless it's Linix then it is

gcc -o myfile myfile.c

Oh, the output from the suggestions posted above will be a file named a.out

Did you mean linux? If so, this works under linux too.

Yes - I can't type. :smiley: or read.

generally u have the cc compiler in the /usr/bin. you can also locate the path using the command type or whence. sometimes the cc compiler may also be onvoked using gcc, c++ (this is for cplus cplus)
and if none of this gives you a confirmative solution, do this
find / -name "*cc" 2>/dev/null

then take a tea break, and when you are back, you will surely have a result by then :slight_smile: a positive or negative, but an almost sure answer to your question.
if it is negative then ask your unix distributor where you should get the c compiler from.

To find out what is installed simply type the command 'cc' on a terminal window. If it is installed, you will probably get a message which reads 'no input file.' If the package is not present, you will get something like 'optional package not installed.'

If the Compiler Collection (cc) packages are not installed, then the easier way is to install the GNU cc package (gcc). You can download it at gcc.gnu.org or one of its mirrors.

Not sure if I should have started a new trend...
I would like to start programming c in UNIX. Can somebody point me to a resource where the UNIX programming tools are explained (autoconf, automake ... ) so that my programms could be installed into system by ./configure && make && make install sequence. Thanks.

cc filename.c /* for compiling */

and

./a.out (or) a.out /* for execution */

Learn makefiles first. autoconf and automake are tools for creating makefiles, if you don't know how the output works you'll be totally lost.

Incidentally, my opinion of these tools is very low... they're slow, cumbersome, error-prone, break backwards compatibility every 5 minutes, and consume huge amounts of space for the work they do. I think you're better off writing your own makefiles.

Hello :

I compiled successfully a "c" program on AIX that works on Slackware.

However, when I tried to execute the program I get "typedef : variable not found" for all variables used in the program.

Can you eplain what I am doing wrong.

Thank you.

kgm.

Tell me what you mean by "compile" and what you mean by "execute" please. Tell me exactly what you did. It makes no sense at all to get typedef errors during execution unless you mean something different.