#include <stdio.h>
#include <string.h>
//***************BUG - spaces in string cause errors!!*******
//char st[]="amanaplanacanalpanama";
char st[] = "race car";
//char st[] = "never odd or even";   
//char st[] = "computers r dumb";



char str_reverse(char arr[], int length){
  int i;
  //int  pal_chk;
  char rev_st[length+1];

  for (i =0; i < length; i++){
    if (arr[i] != '\0'){
      rev_st[length -1- i] = arr[i];
      printf("NULL byte NOT detected\n"); 
    }
    else{
      printf("NULL byte detected\n");
    }
  }
    printf("Original string: %s\nReversed string: %s\n"
	   ,st, rev_st);
    
    if (0==strcmp(st, rev_st)){
      printf("Palindrome?: YES\n");
    }
    else{
      printf("Palindrome?: NO\n");
    }
  
}
  

int main(){
  str_reverse(st, strlen(st)); //compensate for strlen removing terminating NULL byte
  

  return 0;

}

