Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,895 questions

51,826 answers

573 users

How to detect operating system in C

1 Answer

0 votes
#include <stdio.h>

int main() {

#ifdef _WIN32
    printf("Windows 32 bit + 64 bit OS\n");

#elif __APPLE__
    printf("Apple OS\n");

#elif __linux__
    printf("Linux OS\n");

#elif TARGET_OS_IPHONE
    printf("iPhone OS\n");

#elif TARGET_OS_MAC
    printf("MAC OS\n");

#elif__ANDROID__
    printf("Android OS\n");

#elif __unix__
    printf("Unix OS\n");

#elif _POSIX_VERSION
    printf("POSIX OS\n");

#elif BSD
    printf("Solaris OS\n");

#elif __FreeBSD__
    printf("FreeBSD OS\n");

#else
    printf("Other OS\n");
#endif

    return 0;
}



/*
run:

Windows 32 bit + 64 bit OS

*/

 



answered Apr 12, 2022 by avibootz
edited Apr 12, 2022 by avibootz

Related questions

2 answers 122 views
122 views asked Mar 20, 2023 by avibootz
1 answer 120 views
1 answer 104 views
1 answer 156 views
2 answers 205 views
...