Created
August 8, 2014 21:06
-
-
Save P1xt/3b4128fb2c99b55214be to your computer and use it in GitHub Desktop.
Roller Coaster in c++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> // For ifstream | |
#include <string> | |
#include <locale> | |
using namespace std; | |
int main(int argc, char* argv[]) { | |
ifstream file; | |
string line; | |
file.open(argv[1]); | |
std::locale loc; | |
while (!file.eof()) | |
{ | |
getline(file, line); | |
bool capFlag = true; | |
for (string::const_iterator it = line.begin(); it != line.end(); ++it) { if (std::isalpha(*it,loc)) { | |
if (capFlag == true) { | |
cout << toupper(*it,loc); | |
capFlag = false; | |
} else { | |
cout << tolower(*it,loc); | |
capFlag = true; | |
} | |
} else { | |
cout << *it; | |
} | |
} | |
cout << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment