for( cnt=0; str[cnt] != '\0'; cnt++ ){
    buf[cnt] = str[cnt];
  }
  buf[cnt] = '\0';

!=の右の\0の意味がよく分かりません。
\0ではなく、唯の整数なら分かるのですが。