Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.>
- #include "windows.h"
- #include <stdlib.h>
- #include <stdio.h>
- #define PERROR(a) \
- { \
- LPVOID lpMsgBuf; \
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | \
- FORMAT_MESSAGE_FROM_SYSTEM | \
- FORMAT_MESSAGE_IGNORE_INSERTS, NULL, \
- GetLastError(), \
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), \
- (LPTSTR) &lpMsgBuf,0,NULL ); \
- fprintf(stderr,"%s:%s\n",a,lpMsgBuf); \
- LocalFree( lpMsgBuf ); \
- }
- int veces;
- DWORD WINAPI funcionHijo(LPVOID parametro);
- int main(int argc,char* argv) {
- veces = atoi(argv[1]);
- printf("Soy el padre\n");
- fflush(stdout);
- HANDLE hijos[2];
- hijos[1] = CreateThread(NULL, 0, funcionHijo, LPVOID(-), 0, NULL);
- hijos[2] = CreateThread(NULL, 0, funcionHijo, LPVOID(*), 0, NULL);
- // El padre espera
- WaitForMultipleObject(HandlerHijo, INFINITE);
- printf("El hijo ya ha terminado\n");
- getchar();
- return 0;
- }
- DWORD WINAPI funcionHijo(LPVOID parametro) {
- for (int i = 0; i < veces; i++) {
- printf("%c", parametro);
- fflush(stdout);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement