+ 5

What is the exact algorithm for strrev () function in c ?

In c we have a function that reverse a string which is strrev () what is the exact algorithm which is used to reverse a string in c language.

9th Dec 2018, 12:41 PM
kazi sujoy
kazi sujoy - avatar
3 ответов
+ 8
I dont really know the exact algorithm that the strrev function uses to reverse a string, but as we know a string in C is an array of char so if you want to reverse it you can go through it with a for loop, create a new array with same size of original one and assign every index in new array with the opposite index of old array! here is an example of how it can be done: https://code.sololearn.com/c0QeNsH0r0tP/?ref=app
9th Dec 2018, 3:29 PM
Sekiro
Sekiro - avatar
+ 2
Thank you
9th Dec 2018, 3:37 PM
kazi sujoy
kazi sujoy - avatar