execution


1. Create and run a new thread:

#include <thread>

void do_something() {
  // Do something in the new thread
}

int main() {
  std::thread t(do_something);
  t.join();
  return 0;
}

2. Execute a function after a delay:

#include <chrono>
#include <thread>

void do_something() {
  // Do something after a delay
}

int main() {
  std::this_thread::sleep_for(std::chrono::seconds(5));
  do_something();
  return 0;
}

3. Run a function periodically:

4. Execute a function in a separate process:

5. Execute a system command:

6. Open a file:

7. Write to a file:

8. Read from a socket:

9. Write to a socket:

10. Execute a SQL query:

11. Read from standard input:

12. Write to standard output:

13. Execute a function with arguments:

14. Execute a function with a variable number of arguments: