G++ to TC++

  • Thread starter Omid
  • Start date
  • #1
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; 
}
 

Answers and Replies

  • #2
212
0
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
MathematicalPhysicist
Gold Member
4,308
216
actually tc is for win95 and so forth, i actually use it instead dev-cpp for its simplicity.
 
  • #4
182
0
It has problems with "std::" and some other things. It's a must. I need it to be compatible with TC++. Oh please.
 
  • #5
79
0
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
212
0
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
robphy
Science Advisor
Homework Helper
Insights Author
Gold Member
5,680
951
Last edited by a moderator:

Related Threads on G++ to TC++

Replies
3
Views
1K
  • Last Post
Replies
1
Views
3K
  • Last Post
Replies
3
Views
60K
Replies
1
Views
5K
  • Last Post
Replies
4
Views
3K
Replies
2
Views
966
Replies
9
Views
9K
  • Last Post
Replies
2
Views
4K
Replies
3
Views
3K
Top