/***********************************************************************
The function reverse(string s) prints the string s in reverse order.
This implementation does not use recursion.
 ***********************************************************************/
#include <stdio.h>
#include <string.h>

void print_reverse(char* str);

int main() {
  char s[128];
  printf("Enter a string: ");
  fflush(stdout);
  scanf(" %s", s);

  printf("The reverse of %s is \"", s);
  print_reverse(s);
  printf("\".\n");

  return 0;
}

// print input string reversed
void print_reverse(char* str) {
  int len = strlen(str);
  for (int i = len-1; i >= 0; --i) {
    putchar(str[i]);
  }
}