Find the answer to your Linux question:
Results 1 to 8 of 8
how to work c-programmes in ubuntu 8.04?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    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?

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,763

    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
    gcc filename.c
    to compile the program and

    ./a.out
    to execute the binary.
    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

  3. #3
    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.

  4. $spacer_open
    $spacer_close
  5. #4
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,729
    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 is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  6. #5
    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!

  7. #6
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,763

    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 ...
    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

  8. #7
    Linux Guru techieMoe's Avatar
    Join Date
    Aug 2004
    Location
    Texas
    Posts
    9,496
    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

  9. #8
    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...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •