This is how the entire task looks like completely - the main thread creates two other threads suspended and after creating them starts the first one The first of them allocates a memory block of 200Kb in size, fills it with random numbers and starts the second one, which writes the generated random numbers to a file, frees the allocated memory and ends
like this I have at the moment
#include "pch.h" #include <iostream> #include <windows.h> #include "conio.h" #include <vector> //#include "stdafx.h" using namespace std; const int Length =200 * 1024; unsigned char *buffer = new unsigned char[Length]; int num; DWORD WINAPI thread2(LPVOID); DWORD WINAPI thread3(LPVOID); int main() { // create threats HANDLE thread = CreateThread(NULL, 0, thread2, NULL, 0, NULL); HANDLE thread1 = CreateThread(NULL, 0, thread3, NULL, 0, NULL); // stop threads SuspendThread(thread); SuspendThread(thread1); ResumeThread(thread); _getch(); return 0; } DWORD WINAPI thread2(LPVOID t) { for (int i = 0; i< Length; i++) { buffer[i] = (int)rand() % Length + 1; } for (int i = 0; i < Length; i++) { cout « (int)buffer[i] « " "; cout « endl; } delete[]buffer; //cout « "wwwwwwwwwwwwwwwwwwww"; return 0; } DWORD WINAPI thread3(LPVOID n ) { return 0; }
int *Arrand why exactlyint? - AnTints, then why did you select a block of bytes? - AnT