Write a fucntion that will reverse a string?

Write a fucntion that will reverse a string?

char *strrev(char *s)
{
int i = 0, len = strlen(s);
char *str;
if ((str = (char *)malloc(len+1)) == NULL)
/*cannot allocate memory */
err_num = 2;
return (str);
}
while(len)
str[i++]=s[–len];
str[i] = NULL;
return (str);
}



This is one way please specify more wayssssssss...In comments

No comments:

 
Top Blogs