Here is the function:
void reverse(char* str)
{
char * endOfString = str ;
char temp ;
if(str)
{
while(*endOfString)
{
++endOfString;
}
--endOfString ;
while(str < endOfString)
{
temp = *str ;
*str++ = *endOfString ;
*endOfString-- = temp ;
}
}
}
and with this input :
int main()
{
char cStrg[3] = {'a','b','c'} ;
reverse(cStrg)
return 0 ;
}
The output looks like ths:
� % %.
If I enter a bigger input, lets just say :
char cStrg[6] = {'a','b','c','d','e','f'} ;
the output looks like this :
f e d c b a,
which is perfectly fine, does anybody know what I am missing here ?