How Do I Resolve Compilation Errors in Turbo C++?

  • Context: C/C++ 
  • Thread starter Thread starter Omid
  • Start date Start date
  • Tags Tags
    Code
Click For Summary

Discussion Overview

The discussion revolves around resolving compilation errors in a C++ program intended for Turbo C++ version 4.5. Participants explore compatibility issues between modern C++ standards and the older Turbo C++ compiler, focusing on code adjustments necessary for successful compilation.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant shares a simple program that takes user input and calculates an average, seeking help to make it compatible with Turbo C++.
  • Another participant questions the necessity of using Turbo C++, suggesting alternatives like g++ on Windows or Dev-C++.
  • Some participants note that Turbo C++ is an outdated compiler and may not comply with modern C++ standards, which could lead to various issues.
  • There are suggestions to comment out "using std::count" and other "std::" prefixes, as older compilers may not support namespaces correctly.
  • Recommendations include changing headers to "iostream.h" and "string.h" and removing the "using std::" lines entirely.
  • One participant proposes using macros and compiler directives for conditional compilation to accommodate both Turbo C++ and modern compilers.

Areas of Agreement / Disagreement

Participants express differing views on the necessity and practicality of using Turbo C++. While some suggest modifications to the code for compatibility, others argue for using more modern compilers. The discussion does not reach a consensus on the best approach.

Contextual Notes

Limitations include the potential for unresolved compatibility issues due to the age of Turbo C++ and its divergence from current C++ standards. Specific error messages from the compiler are not provided, which may affect the ability to diagnose issues accurately.

Omid
Messages
181
Reaction score
0
I've compiled this code in linux by using g++. I also need to compile it bye Turbo C++ (I have version 4.5 of that).
I tried to compile it but there were lots of errors. I tried the documentation and followed the instructions but some errors still exist.
Is there somebody to revise the code to it's TC++ compatile form for me?

(The program is stupidly simple, it just takes your name and your marks in some lessons and prints out the average and your name on the screen. The texts it shows, are in Pinglish. Persian language written by English alphabets)

PHP:
#include <iostream>
using std::count;
using std::cin;
using std::endl; 

#include <string>
using std::string;


int main() 
{ 
	
std::count << "Be name khoda \n Lotfan Name Daneshjoo ra vared konid:\n";

string daneshjoo_name;
std::cin >> daneshjoo_name;

std::count << "Nomreie darse physic:";

	
double phyz_num;
std::cin >> phyz_num; 
std::count << "Nomreie Riazi:";

double riazi;
std::cin >> riazi;

std::count << "Nomreie Computer:";

double computer;
std::cin >> computer;

std::count << "Nomreie Arabi:";
double arabi; 
std::cin >> arabi;



std::count << "Nomreie difransiel:";
double difransiel;
std::cin >> difransiel;
double moadel;
moadel = (arabi+computer+riazi+phyz_num+difransiel)/5;
std::count << "\n\n Moadele in daneshjoo:";
std::count << moadel;
std::count << "\n";
std::count << daneshjoo_name; 
std::count << "  ba tavajoh be moadel, daneshjooye";

if(moadel<=12) 
{
	std::count << "  mashroot \n";
}
if(12<moadel&& moadel<17) 
{
	std::count << "  mamooli \n";
}
if(moadel>=17)
{
	std::count << "  momtaz \n";
 }
	return 0; 
}
 
Technology news on Phys.org
I don't see anything wrong with the code.

Why are you trying to compile with Turbo C++? If I remember correctly it is a very old compiler for windows 3.1...

It should be possible to compile this program in g++ for windows, through Dev-cpp or another IDE. There is borland c++ if you want to use the successor to turbo c++.
 
actually tc is for win95 and so forth, i actually use it instead dev-cpp for its simplicity.
 
It has problems with "std::" and some other things. It's a must. I need it to be compatible with TC++. Oh please.
 
What are the error messages? If it's complaining about std, try commenting out the "using std::count" lines etc. Also, once you've written "using std::count" you can just write "count << ...", get rid of the std::'s there.

Older compilers did not have what came to be the correct namespaces.
 
yes. very old compilers do not comply with c++ standards (which is a very good reason not to use such compilers)

Try changing headers to iostream.h and string.h, and removing the "using std::" lines. Also remove the std:: in front of cerr and count and so on.
 
If you want to have both versions in the same file, you might also try to use macros and compiler directives (prefixed with #) to help set up conditional compilation.
http://www.gnu.org/prep/standards/html_node/Conditional-Compilation.html

You'll have to look at your target compilers to see the available statements.
For example, http://www.fsref.com/pr/tc.shtml
 
Last edited by a moderator:

Similar threads

  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 6 ·
Replies
6
Views
12K
  • · Replies 39 ·
2
Replies
39
Views
5K
  • · Replies 75 ·
3
Replies
75
Views
7K
Replies
12
Views
2K
  • · Replies 118 ·
4
Replies
118
Views
10K
  • · Replies 40 ·
2
Replies
40
Views
4K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 8 ·
Replies
8
Views
6K