0

Fix the error (segmentation fault)

I'm trying to reverse the string with this code . https://code.sololearn.com/cPypx4wbt196/?ref=app

4th Dec 2019, 2:26 PM
Hima
Hima - avatar
1 Resposta
+ 1
"computer" is a read only string so you cannot modify it. Either use an array, or allocate a string on the heap with malloc. Also, pass the size of the string as a second parameter, don't hardcode the 8. And you're also reversing the string twice.
4th Dec 2019, 4:46 PM
Dennis
Dennis - avatar