找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索

請(qǐng)教Dev-C++ 5.11 如何查看strncmp庫(kù)函數(shù)原型?感謝幫忙

查看數(shù): 1665 | 評(píng)論數(shù): 3 | 收藏 0
關(guān)燈 | 提示:支持鍵盤翻頁(yè)<-左 右->
    組圖打開(kāi)中,請(qǐng)稍候......
發(fā)布時(shí)間: 2022-11-11 16:12

正文摘要:

如題,如下圖,如何能查看strncmp()的函數(shù)體?

回復(fù)

ID:1025655 發(fā)表于 2022-11-15 09:52
angmall 發(fā)表于 2022-11-11 23:08
程序分享出來(lái)給需要的人作參考

感謝!但不是我想要的!我要的是方法!那么多庫(kù)函數(shù)呢!
ID:155507 發(fā)表于 2022-11-11 23:08
程序分享出來(lái)給需要的人作參考

  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ù)制代碼
ID:883242 發(fā)表于 2022-11-11 17:41
想看gcc的庫(kù)源碼,下載glibc慢慢看唄。

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表