#include <stdio.h>
#include <string.h>

int main () {
  
  char str1[] = "string1";
  char str2[] = "string2";
  
/* compares two strings char by char and returns the first difference in their ascii values*/
/* if one is longer it continues comparing and takes only the first extra char and compares with zero */

  printf("Strcmp: %i\n",strcmp(str1, str2));
  printf("*str1: %c\n", *str1);
  printf("*str2: %c\n", *str2);
/* printf(""); */
  int res = string_compare(str1, str2);
  printf("%i\n", res);
}

int
string_compare(char *str1, char *str2)
{
  
  int i;
  while((*str1 != '\n' && *str1 != '\0') || (*str2 != '\n' && *str2 != '\0'))
    {
      if (*str1 < *str2)
	{
	  return *str1 - *str2;
	}
      else if (*str1 > *str2)
	{
	  return (*str1 - *str2);
	}
      (str1)++;
      (str2)++;
        printf("*str1: %c\n", *str1);
	printf("*str2: %c\n", *str2);
    }
  return 0;
}
      
      
  
