How to run two voids

I want to run two voids at once, aka multithreading, for a program that I'm making. I want to make a program that has a timer, and your supposed to cin an answer to a question.

I just need to know how to run two voids exactly at the same time, thanks!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <*stuff*>

using namespace std;

void a()
{
   Beep(1000,1000);
}

void b()
{
   int a;
   cin>>a;
}

int main()
{
   a();//I need to run these two
   b();//lines at the same time
   return 0;
}

Thank you for your help!
They're called functions not voids, You put void there to tell the compiler that a function doesn't return a value.
For concurrent operations you could use std::thread (only available since c++11)
http://www.cplusplus.com/reference/thread/thread/
There is no guarantee that the two threads will run concurrently as it may be faster to run each function one after the other without starting up a new thread(s) (in your example it almost certainly would be faster to not use threads)
ok
Topic archived. No new replies allowed.