Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <string.>
  2. #include "windows.h"
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5.  
  6. #define PERROR(a) \
  7. { \
  8. LPVOID lpMsgBuf; \
  9. FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | \
  10. FORMAT_MESSAGE_FROM_SYSTEM | \
  11. FORMAT_MESSAGE_IGNORE_INSERTS, NULL, \
  12. GetLastError(), \
  13. MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), \
  14. (LPTSTR) &lpMsgBuf,0,NULL ); \
  15. fprintf(stderr,"%s:%s\n",a,lpMsgBuf); \
  16. LocalFree( lpMsgBuf ); \
  17. }
  18.  
  19. int veces;
  20. DWORD WINAPI funcionHijo(LPVOID parametro);
  21.  
  22. int main(int argc,char* argv) {
  23.  
  24. veces = atoi(argv[1]);
  25. printf("Soy el padre\n");
  26. fflush(stdout);
  27.  
  28. HANDLE hijos[2];
  29. hijos[1] = CreateThread(NULL, 0, funcionHijo, LPVOID(-), 0, NULL);
  30. hijos[2] = CreateThread(NULL, 0, funcionHijo, LPVOID(*), 0, NULL);
  31.  
  32. // El padre espera
  33. WaitForMultipleObject(HandlerHijo, INFINITE);
  34. printf("El hijo ya ha terminado\n");
  35. getchar();
  36.  
  37. return 0;
  38. }
  39.  
  40. DWORD WINAPI funcionHijo(LPVOID parametro) {
  41. for (int i = 0; i < veces; i++) {
  42. printf("%c", parametro);
  43. fflush(stdout);
  44. }
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement