0

As of the given below, you can see that the code is different from each other. Plus I want to add that you can use textcolor() in visual C++ or other compilers.

//for visual c++
#include<iostream>
int main()
{

    std::cout<<"Hello World"<<std::endl;

}

and.

//for TurboC
#include<iostream.h>
void main()
{

    cout<<"Hello World"<<endl;

}

and if you have any problem

//again for visual c++
#include<iostream>

using namespace std;

int main()  //just discovered that you can add void in the bracket after the main
{
    cout<<"Hello World"<<endl;
}
DJbrine
  • 1
  • 1
  • 1
    It's a *very* long time since I used Turbo-C(++) but the second snippet shouldn't compile. Maybe Turbo-C adds an implicit `using namespace std;`; if so, that just adds to its problems. – Adrian Mole Sep 04 '22 at 12:05
  • Also, `void main()` is valid in **C** (I *think*, but it may have changed in a recent Standard); but it is *not* valid in **C++** (nor has it ever been, IIRC). Again, Turbo-C may be adding an unhelpful extension. – Adrian Mole Sep 04 '22 at 12:08
  • 1
    Yes, Turbo C and Visual C++ are different. Turbo C was developed by a company called Borland in the mid/late 80s, and subsumed in Turbo C++ in the early 90s. Borland discontinued the "Turbo" brand in the late 90s. Inprise took over Borland and resurrected the "Turbo C++" moniker in the mid 2000s, until Inprise was taken over in about 2015. So there are several possibilities as to what "Turbo" compiler you have. Visual C++ is a Microsoft product. `void main()` has *never* been part of standard C nor of standard C++, but some C and C++ implementations support it as a *non-standard* extension – Peter Sep 04 '22 at 12:25
  • `` was in draft C++ standards in the early/mid 1990s, and was the precursor of what became `` in standard C++ (every ratified C++ standard since 1998 has had ``, none has had ``). `` provided (with some differences) what we now know in C++ standard I/O (`cin`, `cout`, `istream`, etc) but didn't use namespace `std` (i.e. there was no need to use `std::` prefix or `using namespace std` when using facilities from ``). Early Turbo C++ versions date from the mid 90s (as did early versions of Visual C++, BTW) so use that header. – Peter Sep 04 '22 at 12:31
  • If you are comparing Turbo C++ from the late 1990s and msvc in modern Visual Studio you will see that there are a lot of changes in the language in 30+ years. Also since 2011 we have an updated standard every 3 years which msvc supports (c++11, c++14, c++17, c++20). The default for Visual Studio 2015 to 2019 is to use the c++14 standard but you can select a newer standard if you need. – drescherjm Sep 04 '22 at 13:48
  • Which Turbo C? Or do you mean Turbo C++? **Turbo C++** 1.0 came out in 1990, and predates the addition of `namespace` to the language. It's C++ was based on the *de facto* C++ (either C++85 corresponding to TC++PL/1e (1985), or C++89 corresponding to TC++PL/2e (1991) ... been a while so I don't recall the details). I was using Comeau C++, Lattice C++ and SAS/C++ at that time. – Eljay Sep 04 '22 at 13:50
  • @Peter -- and just for completeness, up to the early 1990s the de facto standard for C++ was cfront, originally a C++-to-C compiler developed at Bell Labs under the auspices of Bjarne Stroustrup and a few other clever folks. `` was the header for the standard streams in cfront. Turbo C++ was a direct descendant of cfront, before the C++ standard messed with the header names. – Pete Becker Sep 04 '22 at 14:09
  • @AdrianMole Turbo-C was released in 1987, before the first C standard; and Turbo-C++ was released in 1989, long before the first C++ standard so neither of them are standard-compliant, unlike MSVC – phuclv Sep 04 '22 at 14:15
  • Looking through the comments, maybe my closing this was a bit hasty. Ping me, if anyone thinks it's suitable for reopening. – Adrian Mole Sep 04 '22 at 16:54

0 Answers0