#include<iostream>
#include<string>
using namespace std;
void reverse(char *str);
int main(){
char myString[]="dcba";
//dcba
reverse(myString);
cout << myString <<endl;
system("pause");
return 0;
}
void reverse(char *str) {
char * end = str;
char tmp;
if (str) {
while (*end) { // loop running whenever Null Chrachter is not find:
++end;
}
--end;
while (str <= end) {
tmp = *str;
*str++ = *end;
*end-- = tmp;
}
}
}
#include<string>
using namespace std;
void reverse(char *str);
int main(){
char myString[]="dcba";
//dcba
reverse(myString);
cout << myString <<endl;
system("pause");
return 0;
}
void reverse(char *str) {
char * end = str;
char tmp;
if (str) {
while (*end) { // loop running whenever Null Chrachter is not find:
++end;
}
--end;
while (str <= end) {
tmp = *str;
*str++ = *end;
*end-- = tmp;
}
}
}