作者:
GooLoo (平凡)
2015-08-11 22:40:09開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
DEV C
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
請問一下, 老師說strcmp是從第一個字符開始比,
完全相同輸出0,
左>右,輸出 +的差值
右<左,輸出-的差值
為什麼我編譯後出現+1和-1, 不是+2,-2?
我有試過其它字符,它好像只會出現 0/1/-1 三種
餵入的資料(Input):
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
程式碼(Code):(請善用置底文網頁, 記得排版)
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
int delta1=strcmp("ABC","ABC");
printf("%d\n",delta1);
int delta2=strcmp("ABF","ABC");
printf("%d\n",delta2);
int delta3=strcmp("ABC","ABF");
printf("%d\n",delta3);
return 0;
}
補充說明(Supplement):