0
This code worked in this compiler of SoloLearn but why isn't it working on other compiler? Please Help me.
https://code.sololearn.com/c4b16lgxw8zS/?ref=app Turbo C++ is unable to trace the first while loop of the function definition and also skipping the char declaration in each function. And console entered the 2nd loop around 34 times. And gave the message ABNORMAL PROGRAM TERMINATION after 2-3 special characters. In NotePad++ I'm getting "UP╠ a" after giving the input TIPU.
10 Réponses
+ 4
Turbo C++ is discontinued and hasn't had an updated stable build release since 2006. Use a more modern compiler like gcc.
+ 1
The largest problem is in the while loop on line 18. It decrements pointer 'a' past the beginning of the string. Decrementing stops only when there happens to be a null byte in memory before the string. As the loop continues, it can cause l_ptr to increment past the end of the output buffer, s2. Then it will overwrite other variables on the stack and change r_ptr and l_ptr. Behavior gets unpredictable at that point. (I tested this scenario and determined empirically that it happens).
0
But why the compiler of this app giving the correct output? And isn't it possible to write the code without malloc() or other memory allocation functions?
0
There was problem to Concatenate two strings using function which must return pointer/string to the calling function. I didn't use malloc but it did work.
0
Would you please recommend me some books for C language?
0
Turbo C++ is discountinued and dilapidated for who knows how long. You should use a more modern and updated compiler such as Clang, GCC or MSVC++