Results 1 to 8 of 8
|
|
Enjoy an ad free experience by logging in. Not a member yet? Register.
|
|
-
10-07-2008 #1Just 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?
-
10-07-2008 #2
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
to compile the program andgcc filename.c
to execute the binary../a.out
First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-----
FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org
-
11-08-2008 #3Just 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.
-
11-08-2008 #4
gcc and other neccessary compilers are not pre-installed in Ubuntu.
Execute this
In case your machine doesn't have internet access, execute this first :Code:sudo apt-get update sudo apt-get install build-essential
Code:sudo apt-cdrom add
It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
-
05-05-2009 #5Just 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!
-
05-05-2009 #6
Welcome to Linux Forum
Thanks for your complete step-by-step how to on C . 
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 ...First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-----
FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org
-
05-05-2009 #7
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
-
09-21-2009 #8Just 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...



