Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ifstream myfile ("Save.sav");
- string line = "";
- if (myfile.is_open())
- {
- while ( myfile.good() )
- {
- getline (myfile,line);
- }
- myfile.close();
- line = StaticFunctions::decrypt(line);
- }
- vector<string> splitString = StaticFunctions::splitString(line, 's');
- return atoi(splitString[0].c_str());
- vector<string> StaticFunctions::splitString(string str, char splitByThis)
- {
- vector<string> tempVector;
- unsigned int pos = str.find(splitByThis);
- unsigned int initialPos = 0;
- // Decompose statement
- while( pos != std::string::npos ) {
- tempVector.push_back(str.substr( initialPos, pos - initialPos + 1 ) );
- initialPos = pos + 1;
- pos = str.find(splitByThis, initialPos );
- }
- // Add the last one
- tempVector.push_back(str.substr(initialPos, std::min(pos, str.size()) - initialPos + 1));
- return tempVector;
- string StaticFunctions::decrypt(string decryptThis)
- {
- for(int x = 0; x < decryptThis.length(); x++)
- {
- switch(decryptThis[x])
- {
- case '*':
- {
- decryptThis[x] = '0';
- break;
- }
- case '?':
- {
- decryptThis[x] = '1';
- break;
- }
- case '!':
- {
- decryptThis[x] = '2';
- break;
- }
- case '=':
- {
- decryptThis[x] = '3';
- break;
- }
- case '#':
- {
- decryptThis[x] = '4';
- break;
- }
- case '^':
- {
- decryptThis[x] = '5';
- break;
- }
- case '%':
- {
- decryptThis[x] = '6';
- break;
- }
- case '+':
- {
- decryptThis[x] = '7';
- break;
- }
- case '-':
- {
- decryptThis[x] = '8';
- break;
- }
- case '"':
- {
- decryptThis[x] = '9';
- break;
- }
- }
- }
- return decryptThis;
- }
Add Comment
Please, Sign In to add comment