ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

LinuxÏÂCAT³ÌÐòµÄCʵÏÖ
2014-11-24 07:34:52 À´Ô´: ×÷Õß: ¡¾´ó ÖРС¡¿ ä¯ÀÀ:1´Î
Tags£ºLinux CAT ³ÌÐò ʵÏÖ

LinuxÏÂCAT³ÌÐòµÄCʵÏÖ´úÂëÆ¬¶Î£º


#include
#include
#include
#define BUFSIZ 1024
void error(char *fmt, ...){
va_list args;

va_start(args, fmt);
fprintf(stderr, "error: ");
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
va_end(args);
exit(1);
}
#include "syscalls.h"


main(int argc, char *argv[]){
char buf[BUFSIZ];
int n, f1;
if(argc == 1){
while((n = read(0, buf, BUFSIZ)) > 0){
write(1, buf, n);
}
}
else if(argc == 2){
if((f1 = open(argv[1], O_RDONLY, 0)) == -1){
error("cat: No such file or directory %s", argv[1]);
}else {
while((n = read(f1, buf, BUFSIZ)) > 0){
write(1, buf, n);
}
}
} else {
error("Wait for new version --javawebzwp@gmail.com");
}
}


¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
·ÖÏíµ½: 
ÉÏһƪ£ºHTML5 Ëþ·ÀÓÎÏ··ÖÏí ÏÂһƪ£º¹ØÓÚCÓïÑԵ͍ÒåÓÚÉùÃ÷

ÆÀÂÛ

ÕÊ¡¡¡¡ºÅ: ÃÜÂë: (ÐÂÓû§×¢²á)
Ñé Ö¤ Âë:
±í¡¡¡¡Çé:
ÄÚ¡¡¡¡ÈÝ:

¡¤Linuxϵͳ¼ò½é (2025-12-25 21:55:25)
¡¤Linux°²×°MySQL¹ý³Ì (2025-12-25 21:55:22)
¡¤Linuxϵͳ°²×°½Ì³Ì£¨ (2025-12-25 21:55:20)
¡¤HTTP Åc HTTPS µÄ²î„ (2025-12-25 21:19:45)
¡¤ÍøÕ¾°²È«±ØÐ޿ΣºÍ¼ (2025-12-25 21:19:42)