zoukankan      html  css  js  c++  java
  • 自己写的一个vii总结

    #include<stdlib.h>
    #include<stdio.h>
    #include<unistd.h>
    #include<errno.h>
    #include<error.h>
    #include<string.h>
    int main(int argc ,char **argv)
    {
    if(argc != 2)
    {
    printf("Usage:%s <xxx.c> ",argv[0]);
    exit(0);
    }

    FILE *fp = fopen(argv[1],"a+");
    if(fp == NULL)
    {
    fprintf(stderr,"fopen (%s) is failed:%s ",argv[1],strerror(errno));
    exit(0);
    }

    fputs("#include<stdlib.h> ",fp); //将一个字符串输出到file *stream中。

    fputs("#include<stdio.h> ",fp);
    fputs("#include<string.h> ",fp);
    fputs("#include<error.h> ",fp);
    fputs("#include<errno.h> ",fp);
    fputs("#include<unistd.h> ",fp);
    fputs("#include<strings.h> ",fp);
    fputs("#include<stdbool.h> ",fp);

    fputs("#include<sys/stat.h> ",fp);
    fputs("#include<sys/types.h> ",fp);
    fputs("#include<sys/wait.h> ",fp);
    fputs("#include<fcntl.h> ",fp);
    fputs("int main(int argc,char **argv)",fp);
    int fe = fflush(fp);
    if(fe == EOF)  //error of file
    {
    fprintf(stderr,"flush (%s),failed:%s ",argv[1],strerror(errno));//如果出错,输出错误信息
    }
    fclose(fp);
    // fopen(argv[1],"a+");

    return 0;

    }

    //本程序基本实现了vii的功能,还有一点缺陷就是,运行这个程序之后,所创建的文件不能直接以打开的形式呈现,需要另外vim file.c 才能进入vi界面。需要进一步完善。

  • 相关阅读:
    Todo
    我的类
    Python socket编程之七:多窗口的应用
    iOS与PHP/Android AES128 ECB NoPadding加密
    JSONModel简便应用
    iOS开发系列--UITableView全面解析
    常用方法
    OC和C++混编
    数据层
    block
  • 原文地址:https://www.cnblogs.com/defen/p/5188255.html
Copyright © 2011-2022 走看看