0

Weird behavior

Why there is no output in this code?!! https://code.sololearn.com/c9U7913B7lPB/?ref=app

24th Feb 2019, 8:38 AM
Mostafa Ehab
Mostafa Ehab - avatar
3 Answers
0
Mostafa Ehab SL system dont handle really good errors by compilers
24th Feb 2019, 12:18 PM
KrOW
KrOW - avatar
+ 1
Because it raise a compile time error when you call strrev on snum. The problem is than snum is a pointer to a literal string which compiler store in a constant (eg. not writable area). Because strrev reverse an ASCII string in place, it have to edit (eg. write) the data pointing to snum then, for what i said before, an error happen. One solution is declare snum like an array than is stored onto stack then it can be writable: char snum[] = "anystring"; Anyway, i never seen this function and doing some search on google, it seem to be a not-standard function avaible only on Windows environment.
24th Feb 2019, 9:00 AM
KrOW
KrOW - avatar
+ 1
KrOW thanks man it worked👍, by the way the strrev require string.h but i have another question why it doesn’t give me an error message instead of no output?!
24th Feb 2019, 10:58 AM
Mostafa Ehab
Mostafa Ehab - avatar