|
|
C/C++ is a language with infinite possibilites.
Many of the programs you use have been for the most part
developed in C or C++ and by learning C or C++ you can
create programs and understand how computers function from a
programming stand point.
These tutorials are mostly addressed to
beginners and intermediate programmers but advanced
programmers can also learn a thing or two here! Be aware
that although thousands have used the applications and
source code available on this site we give no guarantee and
are not responsible for anything which may occur from use of
these tutorials.
Compilers:
In order to begin these tutorials you must find
a compiler. There are demo(s) available across the internet
and for the most part you get what you pay for. I currently
use a Macintosh compiler made by http://symantec.com/. If
you have a macintosh then definately consider purchasing
this compiler. If your on a PC then consider Borland's
product or Microsoft Visual C++. However, the best
alternative, by far, is to have access to a Unix or Linux
server. Almost all of them will allow you to use the GNU C
compiler (gcc), and since most servers run Unix flavours
those programs will be able to run on most servers. If you
intend to program C/C++ for the web, access to a Unix/Linux
server is crucial.
What is a compiler?
The webster's dictionary defines the word
compiler as "A program that translates another program
written in a high-level language into machine language so
that it can be executed."
So i'm making the assumption you have a
compiler and its all set up. Let's make the classic hello
world program! Load your compiler. Our program will begin
with the following:
#include <iostream.h>
What exactly is this?
This line is telling the program to include the library
called "iostream.h". Iostream.h is a library which
you'll need in many of your programs. Adding iostream.h to
your program will allow you to send commands to the screen
and take in commands.
Now that you have library add the following
void main()
{
cout<<"Hello world";
}
Whenever you write a program in C or C++, you
have to define a main function. The main function is the
first (and only) function that will be executed. If you fail
to define a main() function, the compiler will refuse to
compile your program. The brackets { and } define an
instruction block. It is a group of instructions that are to
be executed one after the other. When executing the main
function, the program will start at the { and stop at the }.
You can also imbricate brackets, but we'll get back to this
in later lessons.
|
|
|