Comparison of C against C++ – as a beginner

I started teaching myself how to program in C++ today, and here’s the code for the basic “Hello, world” program that everyone starts with, compared to C.

C++

#include // this must be the basic header/footer file

int main()
{
std::cout << "Hello, world!\n"; // this means "print the words just after << "
return 0; // return an integer of 0
}

And now for C


#include

int main()
{
printf("Hello, world!\n"); //Print the words in the brackets
return(0);
}

C looks a lot clearer than C++, but I’m only starting! The book I’m using is called “Teach Yourself C++ in 24 Hours”, so in about 23 hours I’ll have a basic level of knowledge of how use it. Wish me luck…

Advertisements

Tags: , ,

About Philip

I'm a physics graduate, sci-fi writer, budding game designer, and amateur human.

Any comments?

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: