title: How do I declare a bool function in a window.h thread?
body: <p>For my assignment I need to write a multithreaded program that outputs all the prime numbers less than or equal to the number entered by the user, in a separate thread.</p>
  
  <p>I am new to the threads and do not fully understand how to correctly implement them. But I created a boolean function which determines whether an integer is a prime number or not and I named it bool isPrime. However, the bool isPrime gives me the following error "declaration is incompatible with "LPVOID isPrime". I am not sure how to fix it, I've also noticed that my compiler (visual c++) gives a red underline for "cout" and "cin" but if I declare using namespace std, than the compiler underlines the "std" and gives this error "name must be a namespace name", I don't know what it supposed to mean. How could I fix these two problems?</p>
  
  <pre><code>#include &lt;Windows.h&gt;
  
  DWORD Prime;
  
  
  DWORD WINAPI primeThreadFun(LPVOID isPrime)
  {
      bool isPrime(int n)
      {    
          float sqrtn = sqrt(n);
          if (n &lt; 2) return false;
          if (n &lt; 4) return true;
          if (n % 2 == 0) return false;
          for (int d = 3; d &lt;= sqrtn; d += 2)
          if (n % d == 0) return false;
          return true;
      }
  
  }
  
  int main(int argc, char *argv [])
  {
      DWORD ThreadId;
  
      HANDLE ThreadHandle;
  
      int n;
      cout &lt;&lt; "Enter a number: " &lt;&lt; endl;
      cin &gt;&gt; n;
      for (int i = 0; i &lt;= n; i++)
      if (isPrime(i)) cout &lt;&lt; i &lt;&lt; " ";
      cout endl;
  }
  
  ThreadHandle = CreateThread(NULL, 0, primeThreadFun, (LPVOID) isPrime, NULL, ThreadID []);
  
  if (ThreadHandle != NULL)
  {
      WaitForSingleObject(ThreadHandle INFINITE);
  
      CloseHandle(ThreadHandle);
  }
  
  }
  </code></pre>