Question:

Help getting started programming in C using Linux.

by  |  earlier

0 LIKES UnLike

In the past I have dabbled a bit with c and every once in a while I mess around with some web programming i.e. javascript, xhtml, but now i actually want to start programming for real and I decided to start by learning C seeing as how it is the base for c . Right now I am using Ubuntu Linux and I think that since I am not a very adept Linux user it would be a better learning experience. My problem is that I want to compile the most basic of C programs and I can't because I dont have the C libraries. So when I try to compile a program with "#include <stdio.h>" in it the compiler tells me:

samp.c:1:19: error: stdio.h: No such file or directory

samp.c: In function ‘main’:

samp.c:5: warning: incompatible implicit declaration of built-in function ‘printf’

I am using the gcc complier from the command line, so my question is how do I get the library files necessary to get started programming in C.

 Tags:

   Report

2 ANSWERS


  1. Hi

    The &#039;stdio.h&#039; file should be in the &#039;/usr/include&#039; directory.

    In fact if Linux has been properly installed on your system ALL the include files should be there.

    How are you compiling the code?

    g++   or cpp or c++ followed by -o (that&#039;s a lower case letter o) followed by the name of the executable file followed by the program file:

    E.g.

    c++ -o myprog myprog.cpp

    will compile and link myprog.cpp into myprog which you will be able to run by just typing ./myprog on the command line.

    I hope this is of some help to you

    Regards

    G


  2. I have a similar story to you. I will study a programming language vigorously for about two weeks then completely lose interest. I do this with spoken languages too.

    The list of my attempted languages (computer and spoken).

    C

    Visual Basic

    HTML

    Python

    German

    Esperanto

    Italian

    I am using Ubuntu as well, I have been using it for about 6 months. I have started to read the beginner courses at Linux.org . While they do get dry, I would suggest reading them, because they will make you a Linux whiz in no time. Also I would suggest learning python before C. It is easier and thus will take less time and also python is compiled by C, so they probably have some similarities.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.