LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-21-2010, 03:41 PM   #1
MEWjr1
LQ Newbie
 
Registered: Feb 2010
Posts: 5

Rep: Reputation: 0
Programming help


I installed ubuntu on a spare computer that i have and i need to write some simple programs in C. Only problem is that i'm not sure how to do that. Do i need to install some sort of C compiler?
 
Old 02-21-2010, 03:48 PM   #2
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,062

Rep: Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893
You will need a C compiler for this task. You probably already have one though. Any sign of gcc on your system?
 
Old 02-21-2010, 04:06 PM   #3
MEWjr1
LQ Newbie
 
Registered: Feb 2010
Posts: 5

Original Poster
Rep: Reputation: 0
I went to a terminal and entered gcc. The return prompt was "gcc: no input files"

How would i go about making the source code?
 
Old 02-21-2010, 04:23 PM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Generally:

gcc source-file.c -o executable

Then to run the executable type

./executable

If you have more than one source file:

gcc file1.c file2.c ... fileN.c -o executable

If your program has a Makefile, you can compile it simply withthe command

make

Last edited by btmiller; 02-21-2010 at 04:23 PM. Reason: fix typo
 
Old 02-21-2010, 04:38 PM   #5
MEWjr1
LQ Newbie
 
Registered: Feb 2010
Posts: 5

Original Poster
Rep: Reputation: 0
OK. I think i have making and compiling C files down. I need to make an endless loop, and turn it off using kill. How might i make that endless loop?
 
Old 02-21-2010, 04:46 PM   #6
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
Starting to sound like homework to me.
 
Old 02-21-2010, 05:07 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
See the C tutorials http://www.linuxtopia.org/online_books/index.html
http://rute.2038bug.com/index.html.gz
 
Old 02-21-2010, 05:51 PM   #8
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
while [ 1 ]; do echo looping; sleep 1; done
 
Old 02-21-2010, 06:12 PM   #9
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,765
Blog Entries: 27

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Hi,

In addition to the 'RUTE' look at 'Programming General & WEB' section of 'Slackware-Links' for more choices.


The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!z
 
Old 02-21-2010, 06:28 PM   #10
mryuck
Member
 
Registered: Feb 2010
Posts: 107

Rep: Reputation: 23
I hope it is homework!
Schools here are phasing out c++! Nevermind C.
Microsoft must have a hand in what is taught.
 
Old 02-21-2010, 06:30 PM   #11
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,336

Rep: Reputation: 231Reputation: 231Reputation: 231
while(1){/*do something*/}
 
Old 02-21-2010, 07:37 PM   #12
MEWjr1
LQ Newbie
 
Registered: Feb 2010
Posts: 5

Original Poster
Rep: Reputation: 0
It is homework. I used for(; goes on forever.

sleep(?) is that measured in seconds or a smaller value>?

What is the difference between sleep and usleep?
 
Old 02-21-2010, 07:47 PM   #13
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Go read a C tutorial.
 
  


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
New MSN group: programming fans -- enjoy programming lswhbcb Programming 1 06-29-2007 07:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:37 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration