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).
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?
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?