ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi. I have never done unix systems programming before... I am using c but I don't know how to get it to run. I have done shell programming a few days ago... so I am not sure how to get started. I basically typed up a simple hello message in c in a text editor in unix. I did a "chmod u+x t" and a "./t" when it runs it gives me an error about my "int main()" Does somebody know what i am doing wrong? Thanks!
C is a compiled language ... typing it in, and
saving the text-file doesn't make it an executable,
it's just a source file.
Typically you'll save it as test.c (or another name
with the c extension) and then run
gcc test.c -o test
gcc will automatically make test and executable.
./test will run it.
They are indeed ... there is no such thing as
"a Unix program" ... it's either source (which needs
to be compiled on the target platform [yes, I know
there's C interpreters, but that's not the point of this])
or a script (which is interpreted on the fly, e.g. a
bash- or perl-script [yes, I know that there are
perl compilers, but that's not the point of this])
By "creating a Unix program" you could mean
writing source code of some sort or the process
of compiling some source ...
i'll give you an example to help you... I have to write a unix program that searches the specified key word and replaces each occurrence of the key word in the file with the specified new word. The key word, the new word, and the file name must be given as arguments. So I was thinking that it would be like "search word filename" as the command... not telling me how to do it.. could you just tell me how I would compile and run it... also I have to write it in the C language. Thanks!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.