/* * Copyright (c) Hisilicon Technologies Co., Ltd. 2014-2020. All rights reserved. * Description: printf function * Author: SmartMedia_BSP * Create: 2014-06-04 */ #include int strncmp(const char *cs, const char *ct, size_t count) { int res = 0; const char *d = cs; const char *s = ct; if (cs == NULL) { printf("cs is null\n"); return 0; } if (ct == NULL) { printf("ct is null\n"); return 0; } while (count-- && (res = *d - *s) == 0 && *d != '\0' && *s != '\0') { d++; s++; } return res; }