Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //5.uloha
- void clearBuff(string buff[], int count) {
- for (int i = 0; i < count; i++) {
- buff[i] = "";
- }
- }
- string replaceIt(string line) {
- string new_string = "";
- for (int i = 0; i < line.size(); i++) {
- new_string += line[i];
- }
- return new_string;
- }
- string fixLine(string line) {
- string new_string;
- int index = line.size();
- switch (line[index]) {
- case '\n':
- new_string = replaceIt(line);
- return new_string;
- case '\r':
- new_string = replaceIt(line);
- return new_string;
- case '\t':
- new_string = replaceIt(line);
- return new_string;
- case '\b':
- new_string = replaceIt(line);
- return new_string;
- case '\v':
- new_string = replaceIt(line);
- return new_string;
- case '\0':
- new_string = replaceIt(line);
- return new_string;
- default:
- return line;
- break;
- }
- }
- bool Titulky::nacitajZoSuboru(const string &menoSuboru) {
- string buffer[200];
- short loop = 0; //short for loop for input
- string line; //this will contain the data read from the file
- ifstream myfile(menoSuboru); //opening the file.
- if (myfile) //if the file is open
- {
- while (getline(myfile, line)) //while the end of file is NOT reached
- {
- if (line == "") {
- try {
- vlozTitulok(buffer, loop);
- }
- catch (ZlyVstup) {
- }
- clearBuff(buffer, loop);
- loop = 0;
- }
- else if (loop > 1) {
- buffer[loop] = fixLine(line);
- loop++;
- }
- else {
- buffer[loop] = line;
- loop++;
- }
- }
- myfile.close(); //closing the file
- }
- else {
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement