Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I run C and C++ on any platform?

If I write in C or C++ on for example: Windows. Is it guaranteed than I can compile and run it on any other operating system such as Mac OS, Linux, Unix-like systems? So, does it mean C or C++ is cross-platform language?

like image 947
user963241 Avatar asked Nov 30 '12 03:11

user963241


People also ask

Are C programs cross-platform?

The language C itself is cross-platform, because you don't directly run C code on machines. The C source code is compiled to assembly, and assembly is the platform specific code. The only non cross-platform part are the compilers and the resulting assembly.

Does C only run on Linux?

C was pretty much invented to write UNIX, the predecessor of Linux, and most of modern Windows is also written in C/C++, so yes, C compilers are available for both platforms.

In what platforms can I use C++?

When it's installed, you can use C++ to create code that runs on iOS and Android devices and platforms, Windows, Windows Store, and Xbox. Writing code for multiple platforms is often frustrating. The primary development languages and tools for iOS, Android, and Windows are different on each platform.

Is C and C++ platform independent or dependent?

Actually C++ is not a platform dependent, but the output it produces is in .exe or other format which is depend on the platform you are using. so simply C++'s code is independent of platform, just the output comes after compilation is dependent.


1 Answers

If you write a C or C++ program that strictly complies with some standard, then the program should work on any platform that supplies a tool chain that complies with that standard. In that sense, C and C++ are cross-platform languages.

like image 68
David Schwartz Avatar answered Sep 27 '22 22:09

David Schwartz