fork(1) download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. void printer(void * userp)
  5. {
  6. std::string * string = reinterpret_cast<std::string*>(userp);
  7. std::cout << *string << std::endl;
  8. }
  9.  
  10. int main()
  11. {
  12. //Cast the function to a one that takes a void pointer
  13. void(*func)(void*) = &printer;
  14. //Create a string and call the function with it
  15. std::string string = "Hello World";
  16. func(&string);
  17. return 0;
  18. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Hello World