Skip to content

Instantly share code, notes, and snippets.

@P1xt
Created August 8, 2014 21:06
Show Gist options
  • Save P1xt/3b4128fb2c99b55214be to your computer and use it in GitHub Desktop.
Save P1xt/3b4128fb2c99b55214be to your computer and use it in GitHub Desktop.
Roller Coaster in c++
#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