Programming This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
10-03-2004, 08:09 PM
|
#1
|
|
Member
Registered: Apr 2003
Posts: 225
Rep:
|
unix systems programming in c
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!
|
|
|
|
10-03-2004, 08:37 PM
|
#2
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
|
You did compile it, though? Or are you trying to run the source?
Cheers,
Tink
|
|
|
|
10-03-2004, 08:40 PM
|
#3
|
|
Member
Registered: Apr 2003
Posts: 225
Original Poster
Rep:
|
not sure what you mean... but how would you run a c program in unix?
|
|
|
|
10-03-2004, 08:53 PM
|
#4
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
|
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.
Cheers,
Tink
|
|
|
|
10-03-2004, 10:35 PM
|
#5
|
|
Member
Registered: Apr 2003
Posts: 225
Original Poster
Rep:
|
thanks a lot... and is that the same as creating a unix program? (sorry if my qustions are too vague)
|
|
|
|
10-03-2004, 10:51 PM
|
#6
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
|
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 ...
Cheers,
Tink
|
|
|
|
10-03-2004, 11:42 PM
|
#7
|
|
Member
Registered: Jul 2004
Posts: 96
Rep:
|
Hi, check out
www.advancedlinuxprogramming.com
Don't let the name of the book dissuade you, the first chapters are very basic.
Best wishes for your adventure in unix programming.
|
|
|
|
10-04-2004, 09:16 AM
|
#8
|
|
Member
Registered: Apr 2003
Posts: 225
Original Poster
Rep:
|
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!
|
|
|
|
10-04-2004, 09:57 AM
|
#9
|
|
Member
Registered: Jul 2004
Posts: 96
Rep:
|
|
|
|
|
10-04-2004, 10:04 AM
|
#10
|
|
Member
Registered: Apr 2003
Posts: 225
Original Poster
Rep:
|
thanks a lot max.. when you gave me the link of the book, i thought i had to buy it.. didn't know i could view or download it.. thanks.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 12:09 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|