Copying an array to another array but in reverse order

I am trying to copy an array of type char into another array of type chars, in which the copy holds the original array but in reverse order. Idk if i should do it in a for loop or if there is a <cstring> or <cctype> or <cstdio> function i could use to accomplish this. Thanks in advanced.
BTW this is a Palindrome check assignment. So im trying to compare these two arrays to see if they match after i get the copy array reversed.

1
2
3
	for(int n=0, m=strlen(pdromecopy);n<m;n++,m--){
		pdromecopy_two[n]=pdromecopy[m];		
	}  

pdromecopy has my string i want to be reversed into pdromecopy_two
You don't need to create another char array to check if it's a palindrome. Just loop on the original, checking the first and the last, second and second last, etc. You end up checking len / 2 times, where len is the length of the palindrome.
1
2
3
4
5
int len = strlen( pdrome );
for( int i = 0; i < len / 2; i++ ) {
    if( pdrome[i] != pdrome[len - i - 1] )
        // not a palindrome
}
Topic archived. No new replies allowed.