how to get os name in c 2b 2b

Solutions on MaxInterview for how to get os name in c 2b 2b by the best coders in the world

showing results for - "how to get os name in c 2b 2b"
Esteban
23 Nov 2016
1#include <stdio.h>
2
3#if defined(_WIN32) || defined(_WIN64)
4        const char* os = "Windows";
5#else
6#ifdef __linux
7        const char* os = "Linux";
8#else
9        const char* os = "Unknown";
10#endif
11#endif
12
13int main(void)
14{
15   printf("os = %s\n", os);
16   return 0;
17}