#include<stdio.h>
#include<string.h>
// Function to reverse a string
void reverseString( char * str) {
int start = 0 ;
char temp;
while ( start < end) {
// Swap characters
temp = str[ start] ;
str[ start] = str[ end] ;
str[ end] = temp;
// Move towards the middle
start++;
end--;
}
}
int main( ) {
char str1[ 100 ] , str2[ 100 ] ;
printf ( "\n After strcpy(), str1: %s, str2: %s\n " , str1
, str2
) ;
reverseString( str1) ;
printf ( "\n After reverseString(), str1 reversed: %s\n " , str1
) ;
printf ( "str1 and str2 are equal. \n " ) ; else
printf ( "str1 and str2 are not equal. \n " ) ;
printf ( "After strcat(), str1: %s\n " , str1
) ;
return 0 ;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RyaW5nLmg+Ci8vIEZ1bmN0aW9uIHRvIHJldmVyc2UgYSBzdHJpbmcKdm9pZCByZXZlcnNlU3RyaW5nKGNoYXIgKnN0cikgewogICAgaW50IHN0YXJ0ID0gMDsKICAgIGludCBlbmQgPSBzdHJsZW4oc3RyKSAtIDE7CiAgICBjaGFyIHRlbXA7CiAgICAKICAgIHdoaWxlIChzdGFydCA8IGVuZCkgewogICAgICAgIC8vIFN3YXAgY2hhcmFjdGVycwogICAgICAgIHRlbXAgPSBzdHJbc3RhcnRdOwogICAgICAgIHN0cltzdGFydF0gPSBzdHJbZW5kXTsKICAgICAgICBzdHJbZW5kXSA9IHRlbXA7CiAgICAgICAgCiAgICAgICAgLy8gTW92ZSB0b3dhcmRzIHRoZSBtaWRkbGUKICAgICAgICBzdGFydCsrOwogICAgICAgIGVuZC0tOwogICAgfQp9CmludCBtYWluKCl7CiAgICBjaGFyIHN0cjFbMTAwXSxzdHIyWzEwMF07CgogICAgcHJpbnRmKCJlbnRlciBzdHJpbmcgMTogIik7CiAgICBnZXRzKHN0cjEpOwoKICAgIHByaW50ZigiZW50ZXIgc3RyaW5nIDIgOiAiKTsKICAgIGdldHMoc3RyMik7CgogICAgc3RyY3B5KHN0cjEsc3RyMik7CiAgICBwcmludGYoIlxuQ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