On adding "ios_base::sync_with_stdio(false)", code gives SIGSEGV

I had written a code that got accepted for A1 question. AC-code

After that, for the same code, I added “ios_base::sync_with_stdio(false);” statement and submitted. This time it is giving SIGSEGV error. RTE-code

Can anyone explain why does this happen?

After writing that line you cannot use any c language input/output functions like scanf and printf. I see u using that in your code. Replace any instances of scanf by cin and printf by cout and it’ll work if the logic is correct!

4 Likes

to elaborate more:- It doesn’t let any function get its definitions from stdio.h . This makes cin, cout faster. But this also means that the functions scanf and printf start behaving arbitrarily which causes the runtime SIGSEGV - use of undeclared memory.

But it is running fine on my system.

You’d better use a good compiler then.

I use gcc compiler on ubuntu.