標(biāo)題: 請教Dev-C++ 5.11 如何查看strncmp庫函數(shù)原型?感謝幫忙 [打印本頁]

作者: MYJ918    時間: 2022-11-11 16:12
標(biāo)題: 請教Dev-C++ 5.11 如何查看strncmp庫函數(shù)原型?感謝幫忙
如題,如下圖,如何能查看strncmp()的函數(shù)體?


作者: Hephaestus    時間: 2022-11-11 17:41
想看gcc的庫源碼,下載glibc慢慢看唄。
作者: angmall    時間: 2022-11-11 23:08
程序分享出來給需要的人作參考

  1. /* strncmp -- compare two strings, stop after n bytes.
  2.    This function is in the public domain.  */

  3. /*
  4. @deftypefn Supplemental int strncmp (const char *@var{s1}, @
  5.   const char *@var{s2}, size_t @var{n})
  6. Compares the first @var{n} bytes of two strings, returning a value as
  7. @code{strcmp}.
  8. @end deftypefn
  9. */

  10. #include <ansidecl.h>
  11. #include <stddef.h>

  12. int
  13. strncmp(const char *s1, const char *s2, register size_t n)
  14. {
  15.   register unsigned char u1, u2;

  16.   while (n-- > 0)
  17.     {
  18.       u1 = (unsigned char) *s1++;
  19.       u2 = (unsigned char) *s2++;
  20.       if (u1 != u2)
  21.         return u1 - u2;
  22.       if (u1 == '\0')
  23.         return 0;
  24.     }
  25.   return 0;
  26. }
復(fù)制代碼

作者: MYJ918    時間: 2022-11-15 09:52
angmall 發(fā)表于 2022-11-11 23:08
程序分享出來給需要的人作參考

感謝!但不是我想要的!我要的是方法!那么多庫函數(shù)呢!




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1