How to control the number of threads #pragma omp for?

How to control the number of threads in
#pragma omp for 
 for (size_t i = 0; i < N; ++i)
 //code


num_threads(8) says you can't use
I need to allow the user to choose the number of threads in this part of the code, not in the whole program
March 23rd 20 at 18:42
1 answer
March 23rd 20 at 18:44
Solution
Found =)
#pragma omp parallel num_threads(3)
{
#pragma omp for
for (int i = 0; i < 5; ++i)
cout << omp_get_thread_num();
}

Find more questions by tags C++