123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #include <iostream>
- #include <fstream> // debug
- #include <string>
- #include <thread>
- #include <chrono>
-
- int
- main(int argc, char *argv[]) {
-
- // Output for read test.
- if (argc == 2) {
-
- // Write a single line and exit.
- if (std::string(argv[1]) == "write") {
- std::cout << "This is a test";
- std::cout.flush();
- return 25;
-
- }
-
- // Exit without writing anything.
- if (std::string(argv[1]) == "quit") {
- return 25;
-
- }
-
- }
- std::ofstream log("childProgram.log");
- char ch;
- while (std::cin >> ch) {
-
- // Exit?
- if ('q' == ch) {
-
- break;
-
- }
-
- std::cout << (char) std::toupper(ch);
- std::cout.flush();
- log << (char) std::toupper(ch);
- log.flush();
-
- }
- log.close();
- return 25;
-
- }
|