找回密碼 或 安全提問
 註冊
|註冊|登錄

伊莉討論區

搜索
感激所有對伊莉作出奉獻的人尊貴會員無限觀看附件圖片尊貴會員無限看帖不用回覆
出包王女vr幼女mg鬼滅之刃自慰kkbox
abp 906found dessni 344家庭教師金陵春fc2轉生史萊

休閒聊天興趣交流學術文化旅遊交流飲食交流家庭事務PC GAMETV GAME
熱門線上其他線上感情感性寵物交流家族門派動漫交流貼圖分享BL/GL
音樂世界影視娛樂女性頻道潮流資訊BT下載區GB下載區下載分享短片
電腦資訊數碼產品手機交流交易廣場網站事務長篇小說體育運動時事經濟
上班一族博彩娛樂

[繁中]霹靂英雄戰紀之

[簡] 為美好的世界獻

[繁]狼與辛香料 MERCH

(4月新番)[繁]無職轉

(4月新番)[繁]怪獸八

(4月新番)[繁]戰隊大
C & C++ 語言C# 語言Visual Basic 語言PHP 語言JAVA 語言
查看: 714|回復: 0
打印上一主題下一主題

strcmp 做 string_compare[複製鏈接]

in_dependent_ 該用戶已被刪除
跳轉到指定樓層
樓主
發表於 2009-5-15 02:15 AM|只看該作者|倒序瀏覽
如果發覺自己無法使用一些功能或出現問題,請按重新整理一次,並待所有網頁內容完全載入後5秒才進行操作。
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <string.h>

  5. int main(void)
  6. {
  7. char str[1000] = "Hello, world"; // 輸入字串
  8. char str2[6] = "or";
  9. int result; // 比對結果
  10. int i;

  11. //scanf("%s", &str);

  12. result = strcmp ("hello", "hello");
  13. printf ("result:%d\n", result); //=> 0 These two strings are the same. */

  14. result = strcmp ("hello", "Hello");
  15. printf ("result:%d\n", result); //=> 1 Comparisons are case-sensitive. */

  16. result = strcmp ("hello", "world");
  17. printf ("result:%d\n", result); //=> -1 The character 'h' comes before 'w'. */

  18. result = strcmp ("hello", "hello, world");
  19. printf ("result:%d\n", result); //=> -1 Comparing a null character against a comma. */

  20. result = strncmp ("hello", "hello, world", 5);
  21. printf ("result:%d\n", result); //=> 0 The initial 5 characters are the same. */

  22. result = strncmp ("hello, world", "hello, stupid world!!!", 5);
  23. printf ("result:%d\n", result); //=> 0 The initial 5 characters are the same. */

  24. system("pause");
  25. return 0;
  26. }
複製代碼
利用result值可做目標搜尋...
瀏覽完整內容,請先 註冊登入會員
分享分享0收藏收藏0支持支持0
分享使你變得更實在,可以使其他人感到快樂,分享是我們的動力。今天就來分享你的資訊、圖片或檔案吧。

使用道具檢舉

您需要登錄後才可以回帖 登錄 | 註冊

Powered by Discuz!

© Comsenz Inc.

重要聲明:本討論區是以即時上載留言的方式運作,對所有留言的真實性、完整性及立場等,不負任何法律責任。而一切留言之言論只代表留言者個人意見,並非本網站之立場,用戶不應信賴內容,並應自行判斷內容之真實性。於有關情形下,用戶應尋求專業意見(如涉及醫療、法律或投資等問題)。 由於本討論區受到「即時上載留言」運作方式所規限,故不能完全監察所有留言,若讀者發現有留言出現問題,請聯絡我們。有權刪除任何留言及拒絕任何人士上載留言,同時亦有不刪除留言的權利。切勿上傳和撰寫 侵犯版權(未經授權)、粗言穢語、誹謗、渲染色情暴力或人身攻擊的言論,敬請自律。本網站保留一切法律權利。
回頂部