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

  • C/C++
  • Thread starter Omid
  • Start date
  • Tags
    Code
In summary, the conversation discusses compiling a code in linux using g++ and the need for it to also be compatible with Turbo C++ version 4.5. The program is simple and written in Pinglish, which is Persian language using English alphabets. The conversation mentions difficulties in compiling the code and suggests using older compilers or making changes to the code, such as removing "std::" and using macros and compiler directives for conditional compilation.
  • #1
Omid
182
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::cout;
using std::cin;
using std::endl; 

#include <string>
using std::string;


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

string daneshjoo_name;
std::cin >> daneshjoo_name;

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

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

double riazi;
std::cin >> riazi;

std::cout << "Nomreie Computer:";

double computer;
std::cin >> computer;

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



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

if(moadel<=12) 
{
	std::cout << "  mashroot \n";
}
if(12<moadel&& moadel<17) 
{
	std::cout << "  mamooli \n";
}
if(moadel>=17)
{
	std::cout << "  momtaz \n";
 }
	return 0; 
}
 
Technology news on Phys.org
  • #2
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++.
 
  • #3
actually tc is for win95 and so forth, i actually use it instead dev-cpp for its simplicity.
 
  • #4
It has problems with "std::" and some other things. It's a must. I need it to be compatible with TC++. Oh please.
 
  • #5
What are the error messages? If it's complaining about std, try commenting out the "using std::cout" lines etc. Also, once you've written "using std::cout" you can just write "cout << ...", get rid of the std::'s there.

Older compilers did not have what came to be the correct namespaces.
 
  • #6
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 cout and so on.
 
  • #7
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:

1. How do I compile my code in Turbo C++?

To compile your code in Turbo C++, you can press the F9 key or go to the "Run" menu and select "Compile". This will generate an executable file that you can run.

2. What is the difference between compiling and running code?

Compiling is the process of converting your human-readable code into machine-readable instructions. Running code refers to executing the compiled code on your computer.

3. What is the purpose of the "Help" option in Turbo C++?

The "Help" option in Turbo C++ provides access to the user manual and documentation for the software. It can also provide guidance on how to use specific features and troubleshoot common issues.

4. How can I troubleshoot errors while compiling my code in Turbo C++?

If you encounter errors while compiling your code, you can use the "Debug" option in Turbo C++ to identify the specific line of code causing the error. You can also refer to the "Help" documentation or search online for solutions.

5. Can I use Turbo C++ to compile code written in other programming languages?

No, Turbo C++ is specifically designed for compiling C++ code. However, there are other versions of Turbo C++ that support other programming languages such as Turbo Pascal and Turbo Basic.

Similar threads

  • Programming and Computer Science
Replies
22
Views
2K
  • Programming and Computer Science
2
Replies
39
Views
3K
  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Programming and Computer Science
Replies
6
Views
3K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
16
Views
8K
  • Programming and Computer Science
Replies
13
Views
6K
Back
Top