+ 1

Why SoloLearn's compiler is different from Pc's compiler(gcc)?

Since a few days, I've been trying to understand strings in C, specially what happen when \0 is omitted from a string. I noticed that if I declare several arrays, they're placed one above the other one, this happens in SoloLearn's compiler, but in Linux works in a different way, the arrays are placed one down the other one. And there's something strange, the first array is placed, then de third array and then the second, I don't know why this is happening. Here's the code that I used to try in both compilers https://code.sololearn.com/c6t3g01brvrB/?ref=app

8th Apr 2020, 8:56 PM
Alan Villegas
Alan Villegas - avatar
1 Resposta
+ 1
I don't know, Sololearn uses Linux as well and gcc in version 9 which should be the same version that is installed on your system. But I'm pretty sure this behavior is undefined and might vary across multiple compilers. Also compiler flag can make a big difference here. I don't know which compiler flags Sololearn uses but without knowing them you can't exactly create the same binaries. In the end this is not important. It's fun to play for sure, but this has no importance in a real program. Btw. you can also have a look at https://godbolt.org where you can compare the assembler results of different compilers very easily.
8th Apr 2020, 9:07 PM
Aaron Eberhardt
Aaron Eberhardt - avatar