0

Can you give an example of a simple code in C which gives different outputs with different compilers?? Anyone,,,

It can be a simple code.

17th Sep 2018, 10:21 AM
piyush damor
piyush damor - avatar
2 Answers
+ 6
The easiest is to print an uninitialized variable. The value in memory will be dependent on both the compiler and OS. Using #ifdef, you could detect which compiler and write two different programs.
17th Sep 2018, 12:57 PM
John Wells
John Wells - avatar
+ 1
I like the #ifdef route as uninitialised vars will give erratic values on the same compiler. Martin has a great example: https://code.sololearn.com/cgAiPP77spmp/?ref=app
18th Sep 2018, 12:12 AM
non