ENCM 339 Fall 2005 Lab 3 Exercise F Solution

Last modified: Mon Oct 3 15:13:46 MDT 2005
int my_strlen(const char *s)
{
  int result = 0;
  while (*s != '\0') {
    result++;
    s++;
  }
  return result;
}

void my_strcat(char *dest, const char *source)
{
  /* Advance dest to point to '\0' in destination array. */
  while (*dest != '\0')
    dest++;
  
  /* Copy characters from source to destination. */
  while (*source != '\0') {
    *dest = *source;
    dest++;
    source++;
  }
  
  /* Terminate string in destination array. */
  *dest = '\0';
}