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

By Kelly
at 2013-09-05T18:28
at 2013-09-05T18:28
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);
}
--
→ 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);
}
--
Tags:
Linux
All Comments

By Quintina
at 2013-09-10T16:47
at 2013-09-10T16:47
Related Posts
比對二個檔案的問題 cmp或其它方法?

By James
at 2013-09-05T17:12
at 2013-09-05T17:12
Linux和Windows哪個先?

By Ida
at 2013-09-05T16:58
at 2013-09-05T16:58
比對二個檔案的問題 cmp或其它方法?

By Emily
at 2013-09-05T16:01
at 2013-09-05T16:01
3G DONGLE 無法cat ttyUSB裝置

By Kristin
at 2013-09-05T15:35
at 2013-09-05T15:35
KDE Connect

By Frederica
at 2013-09-05T11:08
at 2013-09-05T11:08