I'm writing a program in C on windows that needs to run as many threads as available cores. But I dont know how to get the number of cores. Any ideas?
You can call the GetSystemInfo
WinAPI function; it returns a SYSTEM_INFO
struct, which has the number of processors (which is the number of cores on a system with multiple core CPUs).