ghostbody / 15-cpp-learning

15 c++ learning repository of SDCS SYSU
6 stars 3 forks source link

different output in "eden" and "vs2013" #20

Open JohnTargaryen opened 8 years ago

JohnTargaryen commented 8 years ago

hello +7,i've come across the problem that my program's output is different in eden and in vs2013; when i use the text input given by eden to test my program in vs2013, it gives the correct output.However, when i copy my code to eden, the output become wrong, why is that? could you explain it to me? thanks;

left : my program's incorrect output in eden; right : my program's output in vs2013 4k7 sbv n 5d5 vhre65p d

left : standard output zcs1wzajte gu 9a1f_e84i

ghostbody commented 8 years ago

@JohnTargaryen

There will be many reasons. What I know is that there will be some "undefined behaviors". This behaviors is not standard c++ which will lead to different outputs with different compilers.

undefined behaviors

Also, multi-thread programming will lead to different answers, but this seems not your circumstance.

I found some interesting answers in stackoverflow through google. Maybe you can search something you need.

different result with VS and gcc