Skip to content

Instantly share code, notes, and snippets.

@peaceman
Created April 12, 2011 08:30
Show Gist options
  • Save peaceman/915175 to your computer and use it in GitHub Desktop.
Save peaceman/915175 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <fstream>
#include <conio.h>
const std::string inputFileName = "h:/namen.txt";
const std::string outputFileName = "h:/logins.txt";
int main() {
std::ifstream inputFile(inputFileName.c_str(), std::fstream::in);
std::ofstream outputFile(outputFileName.c_str(), std::fstream::out);
std::string loginName, actualLine;
if (inputFile.fail() || outputFile.fail()) {
std::cout << "Konnte eine der beiden Dateien nicht oeffnen" << std::endl;
getch();
exit(1);
}
while (std::getline(inputFile, actualLine)) {
int posOfDel = actualLine.find_first_of(' ');
if (posOfDel < 6) {
loginName = actualLine.substr(0, posOfDel);
std::transform(loginName.begin(), loginName.end(), loginName.begin(), toupper);
while (loginName.length() < 6) {
loginName += 'x';
}
} else {
loginName = actualLine.substr(0, 5);
std::transform(loginName.begin(), loginName.end(), loginName.begin(), toupper);
}
loginName += actualLine.substr(posOfDel + 1, 2);
outputFile << loginName << std::endl;
}
inputFile.close();
outputFile.close();
getch();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment