LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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


Reply
  Search this Thread
Old 10-03-2004, 08:09 PM   #1
saiz66
Member
 
Registered: Apr 2003
Posts: 225

Rep: Reputation: 30
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!
 
Old 10-03-2004, 08:37 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
You did compile it, though? Or are you trying to run the source?


Cheers,
Tink
 
Old 10-03-2004, 08:40 PM   #3
saiz66
Member
 
Registered: Apr 2003
Posts: 225

Original Poster
Rep: Reputation: 30
not sure what you mean... but how would you run a c program in unix?
 
Old 10-03-2004, 08:53 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
 
Old 10-03-2004, 10:35 PM   #5
saiz66
Member
 
Registered: Apr 2003
Posts: 225

Original Poster
Rep: Reputation: 30
thanks a lot... and is that the same as creating a unix program? (sorry if my qustions are too vague)
 
Old 10-03-2004, 10:51 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
 
Old 10-03-2004, 11:42 PM   #7
max_sipos
Member
 
Registered: Jul 2004
Posts: 96

Rep: Reputation: 15
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.
 
Old 10-04-2004, 09:16 AM   #8
saiz66
Member
 
Registered: Apr 2003
Posts: 225

Original Poster
Rep: Reputation: 30
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!
 
Old 10-04-2004, 09:57 AM   #9
max_sipos
Member
 
Registered: Jul 2004
Posts: 96

Rep: Reputation: 15
http://www.advancedlinuxprogramming....with-linux.pdf

see section 1.2 - compiling with gcc
 
Old 10-04-2004, 10:04 AM   #10
saiz66
Member
 
Registered: Apr 2003
Posts: 225

Original Poster
Rep: Reputation: 30
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
UNIX Sound Systems TGWDNGHN General 3 11-22-2005 02:33 PM
[c] unix systems programming in MS VS C++? saiz66 Programming 2 10-07-2004 08:16 AM
Any good unix systems programming book? saiz66 Programming 7 10-04-2004 07:16 PM
UNIX (Linux, BSD, etc) Programming :: UNIX kuphryn Programming 8 04-04-2004 11:50 PM
switching hard drives from different UNIX OS systems hopbalt Solaris / OpenSolaris 6 08-06-2003 01:48 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration