Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //skriv till
- int main()
- {
- int rows;
- string fileName;
- ofstream outfile;
- cout << "Enter number of rows: ";
- cin >> rows;
- cout << "Enter the file name: ";
- cin >> fileName;
- outfile.open("C:\\Users\\elvir\\Desktop\\IoT\\C++\\Labbar\\" + fileName + ".txt", ofstream::out | ofstream::app);
- string newline;
- for (int i = 0; i < rows; i++)
- {
- cout << "Enter line " << i + 1 << ": ";
- cin.ignore();
- getline(cin, newline);
- outfile << newline << endl;
- }
- outfile.close();
- }
- // slå ihop
- int main()
- {
- string fileName1, fileName2, fileName3;
- cout << "Enter the first file name: ";
- cin >> fileName1;
- cout << "Enter the second file name: ";
- cin >> fileName2;
- cout << "Enter the third file name: ";
- cin >> fileName3;
- ofstream outfile;
- ifstream infile1, infile2;
- outfile.open("C:\\Users\\elvir\\Desktop\\IoT\\C++\\Labbar\\" + fileName1 + ".txt", ofstream::out | ofstream::app);
- infile1.open("C:\\Users\\elvir\\Desktop\\IoT\\C++\\Labbar\\" + fileName2 + ".txt", ifstream::in);
- string line;
- while (!infile1.eof())
- {
- getline(infile1, line);
- outfile << line << endl;
- }
- infile1.close();
- infile2.open("C:\\Users\\elvir\\Desktop\\IoT\\C++\\Labbar\\" + fileName3 + ".txt", ifstream::in);
- while (!infile2.eof())
- {
- getline(infile2, line);
- outfile << line << endl;
- }
- infile2.close();
- outfile.close();
- }
- //To lower
- int main()
- {
- ofstream outfile;
- ifstream infile;
- outfile.open("C:\\Users\\elvir\\Desktop\\IoT\\C++\\Labbar\\lower.txt", ofstream::out | ofstream::app);
- infile.open("C:\\Users\\elvir\\Desktop\\IoT\\C++\\Labbar\\test1.txt", ifstream::in);
- string line;
- while (!infile.eof())
- {
- getline(infile, line);
- for (char ch : line)
- {
- ch = tolower(ch);
- outfile << ch;
- }
- outfile << "\n";
- }
- }
- //To lower del två
- int main()
- {
- vector<char> vowelList = { 'a', 'e', 'i', 'o', 'u', 'y' };
- ofstream outfile;
- ifstream infile;
- outfile.open("C:\\Users\\elvir\\Desktop\\IoT\\C++\\Labbar\\vowelUpper.txt", ofstream::out | ofstream::app);
- infile.open("C:\\Users\\elvir\\Desktop\\IoT\\C++\\Labbar\\lower.txt", ifstream::in);
- string line;
- while (!infile.eof())
- {
- getline(infile, line);
- for (char ch : line)
- {
- if (find(vowelList.begin(), vowelList.end(), ch) != vowelList.end())
- {
- ch = toupper(ch);
- outfile << ch;
- }
- else
- {
- outfile << ch;
- }
- }
- outfile << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement