Skip to content

Oh yeas from chapter 1

November 18, 2013

Reading through my Teach yourself C book and coming across “ahas and oh yeas”…..and just points that strike me that I would like to try to remember, so, write it down!!!

The latest version of C is  ANSI 11 (2011)

The ANSI standard for C provides for portability across platforms.

C is modular.

Code is written in modules or functions (I wonder how different that is from a class)? I think I know…

This is old school, functional language, everything is not object oriented, which to me overcooks things a little anyway.

Code is organized into functions or routines that can accept parameters or arguments that allow the function to be reusable.  Old school concept…well, at least a very will know and understood concept.

Know your problem.  If you cant state the problem clearly, you wont be able to solve it cleanly.  So, it seems obvious, but be able to state what you are writing your program to do.  Like

read numbers from a file and create a total and average


count the number of times a value greater than 100 is read from a data file


accept a number from a console and write it to a data file

Once you have stated your problem, then you can begin creating an outline to solve the problem.   You can start to see the high level steps needed to solve the problem.  Problem solving is often times a linear process.

In C, create the source code, that’s the commands you type and save in the actual C language.  That source code is then compiled into machine code to be run.

Choose an editor.  You will need a editor where you could write your C code.  Most editors come with tools that help you to write the code better and with help in using the language syntax.  You could even write the code using notepad or a very basic editor.   In Unix systems, you could use the VI editor.  In a Windows system, you could use notepad.

Save the C source code as filename.c  C source code must end in .c, that is what a C compiler is expecting.

When C source code compiles successfully, it create object code.  The object code is what runs at the machine level.  Don’t confuse object code with object oriented programming, very different concepts.

Like all good mature language, C has lots of pre-written functions stored in a *library that you can access and include in your programs.  This is very standard protocol for high level languages like C, Java, PHP and others.  You do not have to write every piece of code that you wish to use.  Many of the things you want to do are already solved and stored in a file that is part of the pre-existing library of code.  You simply have to include that library file in your program.

Creating the Helloworld.c file.  I am using he Dev-C++ V 4.9 editor to create my source code.  Here is a glimpse  of my helloworld source code.


I can compile and run this source code file using the Execute menu provided by the IDE.  I used the command prompt to run the executable file.

The better the IDE, the better the error reporting when you inevitably make mistakes in your syntax.  A semi colon indicates the end of line, removing one from the end of a line produces a predictable error message when you attempt to compile the code.

Note that even in our initial hello world program, we include a reference to a library file.  #include <filename>.


From → C programming

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: