It should be just a single line.Just use the pointers
What is the code for the reversal of string in c?
void StrReverse4(char *str)
{
if(*str)
{
StrReverse4(str+1);
putchar(*str);
}
}
Try this code it might work
Reply:#include %26lt;stdio.h%26gt;
#include %26lt;string.h%26gt;
int main(void)
{
char str1[] = "This is a test sentence";
char str2[80], *p1, *p2;
/* make p point to end of str1 */
p1 = str1 + strlen(str1) - 1;
p2 = str2;
while(p1 %26gt;= str1)
*p2++ = *p1--;
/* null terminate str2 */
*p2 = '\0';
printf("%s %s", str1, str2);
return 0;
}
Sorry mate, got the entire program for your question! :)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment