Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <pthread.h>
  4. #include <unistd.h>
  5. #include <string.h>
  6.  
  7. void* print_message( void *ptr ){
  8. char *message;
  9. message = (char *) ptr;
  10. int end;
  11. end = strlen(message) - 1;
  12. int x;
  13. for (x = end; x >= 0; --x) {
  14. printf("%c", message[x]);
  15. }
  16. return NULL;
  17. }
  18.  
  19. int main(){
  20. pthread_t thread1;
  21. char *message = "Hello World!";
  22. if (pthread_create( &thread1, NULL, &print_message,
  23. (void*)message)){
  24. fprintf(stderr,"thread error\n");
  25. exit(1);
  26. }
  27. sleep(1);
  28. exit(0);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement