Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Write an article for LinuxForums Today! Win Great Prizes!
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > Linux Programming & Scripting > How do I do C Programming in Ubuntu?

Forgot Password?
 Linux Programming & Scripting   C, Perl, PHP, Bash Scripts, anything programming or script related post in here!

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Closed Thread
 
Thread Tools Display Modes
Old 10-07-2008   #1 (permalink)
Just Joined!
 
Join Date: Sep 2008
Location: shimoga,karnataka,india
Posts: 10
How do I do C Programming in Ubuntu?

how to work c-programmes in ubuntu 8.04?
prashasti.p is offline  



Old 10-07-2008   #2 (permalink)
Linux Engineer
 
Lakshmipathi's Avatar
 
Join Date: Sep 2006
Location: 3rd rock from sun - Often seen near moon
Posts: 1,216
Post

I believe all distro comes with gcc complier for c.

so after creating a C file using editor (like gedit or vi ) ,

use terminal to run following command
Quote:
gcc filename.c
to compile the program and

Quote:
./a.out
to execute the binary.
__________________
- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
Lakshmipathi is offline  
Old 11-08-2008   #3 (permalink)
Just Joined!
 
Join Date: Sep 2008
Location: shimoga,karnataka,india
Posts: 10
neither gcc filename.c nor cc filename.c are working.
it is saying gcc command not found.cc command not found.
prashasti.p is offline  
Old 11-08-2008   #4 (permalink)
Super Moderator
 
devils casper's Avatar
 
Join Date: Jun 2006
Location: Chandigarh, India
Posts: 21,596
gcc and other neccessary compilers are not pre-installed in Ubuntu.
Execute this
Code:
sudo apt-get update
sudo apt-get install build-essential
In case your machine doesn't have internet access, execute this first :
Code:
sudo apt-cdrom add
__________________
It takes a lot of time to be a genius, you have to sit around so much doing nothing, really doing nothing. - Gertrude Stein
New Users: Read This First
devils casper is offline  
Old 05-05-2009   #5 (permalink)
Just Joined!
 
Join Date: May 2009
Posts: 1
C Programming in Ubuntu

To C program in Ubuntu, follow the following steps:
1. Click on Places on menu bar > go to Home Folder.
2. A new window appears containing folders like
3. Here rightclick
on your mouse button > Create Document > click on Empty File.
4. Select the file > press F2 > rename it as neilay.c.
5. Double click on neilay.c.
6. There you type the simplest C Code:
#include<stdio.h>
int main()
{
printf("Neilay from India\n");
return 0;
}
7. Save and minimize everything.
8. Click on Applications on the menu bar > Accessories > click on Terminal.
9. A new window appears and since my username is “neilay”, neilay@ubuntu: ~ appears on its
title bar as default – this will be different in your case.
10. Now neglecting everything, just type: gcc neilay.c and press the Enter key.
11. Wait and if your code is correct no error will be found and simply neilay@ubuntu: ~ $ will be
appeared and indicates you can execute this compiled file.
12. Now type: ./a.out and press the Enter key and see how nicely your file is executed!
13. This procedure must work with both Ubuntu and Fedora. If it is not working, then definitely
your OS has got problem with it. This happened to me too. Earlier my friend gave me a pirated
CD of Ubuntu and there this method failed. Later if ordered for a Ubuntu CD for free and when
it came I installed it onto my hard disk and got the above procedure is working correctly. I don't
know why! And “if no input files” error appears while executing, make sure that you have
placed your source file in appropriate folder or location. For me – neilay@ubuntu: ~ appears on
the title bar of the terminal – I have simply placed the file in neilay folder
14. That's all about Ubuntu C Programming. If it works nicely as well as you got problem with it,
kindly feel free to drop a comment. Happy programming!
neilay is offline  
Old 05-05-2009   #6 (permalink)
Linux Engineer
 
Lakshmipathi's Avatar
 
Join Date: Sep 2006
Location: 3rd rock from sun - Often seen near moon
Posts: 1,216
Smile

Welcome to Linux Forum Thanks for your complete step-by-step how to on C .


Quote:
Originally Posted by neilay View Post
a pirated CD of Ubuntu
Why Pirated Ubuntu ? They offer free edition . You can request a CD from their site (https://shipit.ubuntu.com/) They will sent a copy in 4 weeks time. I received one CD from them.

Happy Programming ...
__________________
- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
Lakshmipathi is offline  
Old 05-05-2009   #7 (permalink)
Super Moderantor
 
techieMoe's Avatar
 
Join Date: Aug 2004
Location: Texas
Posts: 9,334
There is no such thing as a pirated version of Ubuntu. The operating system is free to distribute as you see fit. The only thing you need to worry about is where your CD image comes from. As long as it's the official Ubuntu site or an official mirror, you're good to go.
__________________
Registered Linux user #270181
TechieMoe's Tech Rants
techieMoe is offline  
Old 09-22-2009   #8 (permalink)
Just Joined!
 
Join Date: Sep 2009
Posts: 1
I've got a little question though... I can compile code without any problem, but when I try to run the executable (.out), instead of displaying the text it should, it gives me

bash: ./a.: No such file or directory

I triple checked my code, and it was correct. I even tried with the simple code nailay posted here, but it's the same... Any suggestions??

EDIT: Problem solved, I was using the incorrect filename and I had omitted the ".out" extension...
Redblade3 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 12:29 PM.






© 2000 - - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.1