Mac Compiling code from visual studio in xcode c++

ninjonxb

macrumors newbie
Original poster
Nov 17, 2009
6
0
I have some c++ code that is fairly basic. This code works perfectly in visual studio on windows but when i try the code in c++ i get runtime errors (i am asuming, I cant understand what it is telling me).
PHP:
#include <iostream>	
#include <string>
using namespace std;	

int main () {
	
	string pswd;
	string const PASSWORD = "CPLUS";
	int numtries = 0, test;
	
	do {
		cout << "please enter password:";
		getline(cin, pswd);
		test = PASSWORD.compare(pswd);
		if (test == 0)
		{
			cout << "you are correct." << endl;
			break;
		}
		else {
			cout << "please try again";
			numtries ++;
		}

	} while (numtries < 3);
		if (numtries = 3) {
			cout << "sorry, to many wrong password attempts";
		}
	
	return 0;
}
I wanted to use a simplier program that uses a good variety of things to see if it works. And it seems like i start running into problems when I am using getline and strings.

Is there something special I have to do, to run standard C++ code?
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
1
Dallas, TX
Copy and paste your output. You said you don't understand it, so it seems best that you give us a chance to help.

-Lee
 
Comment

ninjonxb

macrumors newbie
Original poster
Nov 17, 2009
6
0
ok, well that worked. Am I just asking for more headaches by trying to do this on xcode than just running windows virtualy or booting into it (as i do now) ?
 
Comment
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.