比對二個檔案的問題 cmp或其它方法? - Linux

Table of Contents

※ 引述《hgs1906 (受遺棄之子)》之銘言:
→ hgs1906:怕謝 想來想去還是不知道具體的寫法 OTZ

本來想用推文來貼以下程式, 後來想想還是回文比較快, 用 cc 編譯後就能用了。
LINES 看你想指定多少。回傳值 0 代表讀到的行數到達了 LINES, 回傳 1 則是
讀到的行數小於LINES

#include <stdio.h>
#include <stdlib.h>

#define LINES 10

main(int argc, char *argv[]) {

int c, l=0;

while ((c=getchar())!=EOF) {
if (c=='\n') {
l++;
if (l==LINES)
exit(0);
}
}
exit(1);
}


--

All Comments

Quintina avatarQuintina2013-09-10
感謝您的幫忙 拜謝OTZ