Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

childProgram.cpp 730B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <iostream>
  2. #include <string>
  3. #include <thread>
  4. #include <chrono>
  5. int
  6. main(int argc, char *argv[]) {
  7. // std::this_thread::sleep_for(std::chrono::milliseconds(150));
  8. // Output for read test.
  9. if (argc == 2) {
  10. // Write a single line and exit.
  11. if (std::string(argv[1]) == "write") {
  12. std::cout << "This is a test";
  13. std::cout.flush();
  14. return 25;
  15. }
  16. // Exit without writing anything.
  17. if (std::string(argv[1]) == "quit") {
  18. return 25;
  19. }
  20. }
  21. char ch;
  22. while (std::cin >> ch) {
  23. // Exit?
  24. if ('q' == ch) {
  25. break;
  26. }
  27. std::cout << (char) std::toupper(ch);
  28. std::cout.flush();
  29. }
  30. return 25;
  31. }