摘要: char *gets(char *str);str 的结束符 \0, \n; 无最大长度; 不接收\nchar *fgets(char *str, int maxlen, FILE *fp);str 的结束符\0; 最大长度 maxlen; 接收\n---------------------size_t read(int fd, void *buf, size_t count);从fd中读入count个字符到buf中;write(int fd, const void *buf, size_t count);把buf 中的count个字符写入到fd中;注意 当buf为字符串时,记得要把最后的\0 阅读全文
posted @ 2012-08-21 15:07 庄庄庄 阅读(136) 评论(1) 推荐(0) 编辑
摘要: 竖直方向分屏:vsplit 2.c:vs 2.c切换窗口ctrl ww----------------- 下午#include <stdio.h>#include <stdlib.h>#include <ctype.h>#include <unistd.h>#define LEN 1024#define R 0#define W 1void trans(char *s){ char ch; while(ch = *s) *s++ = toupper(ch); *s = 0;}int main(){ int pipe_a2b[2]; int pip 阅读全文
posted @ 2012-08-21 13:50 庄庄庄 阅读(351) 评论(1) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>#include <sys/unistd.h>#include <fcntl.h>#include <sys/wait.h>int main(int argc, char *argv){ pid_t pid = fork(); if(pid < 0){ perror("fork"); exit(0); } if(pid == 0){ // child process int n = 8; while(n--){ printf(" 阅读全文
posted @ 2012-08-21 10:49 庄庄庄 阅读(222) 评论(0) 推荐(0) 编辑