I have started learning C++ for my programming class. I have downloaded this "Hello World" program:
#include <iostream> using namespace std; int main() { cout << "Hello, World!"; return 0; }
but Turbo C++ complains:
Error D:\HELLO.CPP 1: Unable to open include file 'IOSTREAM' Error D:\HELLO.CPP 2: Declaration syntax error Error D:\HELLO.CPP 6: Undefined symbol 'cout'
What's wrong with this very simple program? How can I correct these errors?
Turbo C is one such compiler for windows operating system. If you are running a Linux operating system, you can use the GCC compiler. A compiler does the job of converting codes written in C language to machine language, so that it can be executed.
In the previous article, you learned how to install a Turbo C++ compiler on a windows system. After installation you must write your first C program ,and compile it. In this article you will learn to compile your first C program. Prerequisite to this article is installing turbo C++ compiler on your windows computer.
If the compiler uses C++ to compile C code you might have issues if in the C code you use words that are reserved in C++. Will compile fine with a C compiler (or C++ compiler in C mode), but will not compile with a C++ compiler.
There's no problem with this program. (Except probably some stylistic issues — using namespace std
is not recommended). The problem is with Turbo C++. It is a very old piece of software. It implements a dialect of C++, so-called pre-ANSI C++, that has completely fallen out of use by the beginning of this millennium. The first ANSI standard for C++ was published in 1998, then there was the 2003 version, the 2011 version, the 2014 version, the 2017 version, and now we expect the 2020 version to be officially published. Each of these standard revisions brought more or less significant changes to the language.
For Turbo C++ you have to modify the program like this:
#include <iostream.h> // note the .h suffix // using namespace std; // Turbo C++ doesn't implement namespaces int main() { cout << "Hello, World!"; return 0; }
If you look at this program, the difference between the modern C++ dialect and the one accepted by Turbo C++ may seem small. However it will grow much larger as your programs will be getting more complex.
While you can learn programming using Turbo C++ I would strongly recommend to avoid that if humanly possible because of the following problems:
There are many modern free (as in beer, as well as in speech) compilers and IDEs you can use in place of Turbo C++. Some of these include:
Regrettably, some schools/teachers appear to force students to use Turbo C++ even in this day and age. Unfortunately this is not something this community can fix. If you find yourself in this situation, prepare to not being able to get much outside help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With