one thing comes to mind
Code:
//C++
#include <iostream>
#include <string>
void reverse(std::string &str)
{
char tmp;
for(int i=str.size()-1, j=0; i > j; i--, ++j)
{
tmp=str[i];
str[i]=str[j];
str[j]=tmp;
}
}
int main(){
std::string foo("string");
std::cout << foo << std::endl;
reverse(foo);
std::cout << foo << std::endl;
return 0;
}
Code:
/* C */
#include <stdio.h>
#include <string.h>
void reverse(char str[])
{
char tmp;
int i = strlen(str)-1, j=0;
for(; i > j; i--, ++j)
{
tmp=str[i];
str[i]=str[j];
str[j]=tmp;
}
}
int main(){
char foo[] = "string";
printf("%s\n", foo);
reverse(foo);
printf("%s\n", foo);
return 0;
}