So this is a beginners question. I don't know much about compilers so correct me if I'm wrong.
I'm in (equivalent) of grade 11. In school, the computers have Turbo c++ installed.
It doesn't support many things! (or am I doing it wrong?)
string mystring // doesnt support string data type!
And I must give a .h for header files(I thought that was old?)
So which part am I doing wrong?
At home I use Microsoft visual c++ on Windows 8 and g++ on linux.
Both the above examples work fine.
It doesn't support many things! (or am I doing it wrong?)
Turbo C++ was created prior to the C++ standard so it does many thing differently than modern compilers. While it does have a string class it uses a different header file and is not quite the same as the string classes contained in the more modern compilers you use at home. If I remember correctly the header file for the string class in Turbo-C++ is <cstring.h>. But unless you can find some documentation for Turbo-C++ I wouldn't recommend using a string with this compiler because of the differences. I will also say that there are many differences with the standard C++ and Turbo-C++ that you should be talking to your instructors about using a compiler that is probably older than they are. That compiler is so outdated that it should be left in the museum along with all the other relics from by gone eras.
And I must give a .h for header files(I thought that was old?)
Yes using the .h suffix for the "standard" headers is old, as old as the compiler you're trying to use. Also note that Turbo-C++ doesn't know about namespaces either.
At home I use Microsoft visual c++ on Windows 8 and g++ on linux.
Both the above examples work fine.
Actually the snippet you provided should fail on all the compilers you've mentioned, you have a semicolon that is either in the wrong place or not required. Here are the errors I got with my modern compiler:
1 2 3 4 5 6 7 8 9 10 11
#include <iostream>
usingnamespace std;
int main ()
{
char a;
while(cin >> a;)
return 0;
}
main.cpp||In function ‘int main()’:|
main.cpp|8|error: expected ‘)’ before ‘;’ token|
main.cpp|8|error: expected primary-expression before ‘)’ token|
main.cpp|8|error: expected ‘;’ before ‘)’ token|
I used Turbo C++ a long long time ago (1994) for a little while on an old MSDOS machine teaching myself some C++ (now mostly forgotten) with the book, "Using Turbo C++". Surely you have been provided with some similiar text book?
The code examples seem to use the includes,
#include <conio.h>
#include <stdio.h>
and some just have,
#include <iostream.h>