C++ examples for Data Type:char array
Make a reverse copy of a string.
#include <iostream> #include <cstring> using namespace std; void revstrcpy(char *rstr, const char *orgstr) { rstr += strlen(orgstr);/*from ww w . j a v a 2 s .c o m*/ *rstr-- = '\0'; while(*orgstr) *rstr-- = *orgstr++; } int main() { char str[5] = "abcd"; char rev[5]; revstrcpy(rev, str); cout << rev; return 0; }