首页 > 其他 > 详细

创建 cpp 脚本

时间:2015-05-20 02:16:05      阅读:150      评论:0      收藏:0      [点我收藏+]
str=$1
f()
{
    echo "#include <stdio.h>" > $str
    echo "#include <stdlib.h>" >> $str
    echo "#include <string.h>" >> $str
    echo "#include <unistd.h>" >> $str
    echo "#include <ctype.h>" >> $str
    echo "#include <stdlib.h>" >> $str
    echo "#include <dirent.h>" >> $str
    echo "#include <time.h>" >> $str
    echo "#include <sys/types.h>" >> $str
    echo "#include <errno.h>"  >> $str
    echo "#include <string>" >> $str
    echo "#include <vector>" >> $str
    echo "#include <map>" >> $str
    echo "#include <iostream>" >> $str
    echo "" >> $str
    echo "using namespace std;" >> $str
    echo "" >> $str
    echo "int main(int argc,char *argv[])" >> $str
    echo "{" >> $str
    echo "" >> $str
    echo "  cout<<\"hello world\"<<endl;" >>$str
    echo "" >> $str
    echo "  return 0;" >> $str
    echo "}" >> $str
}
if [ $# != 1 ]
then 
    echo "请输入 文件名"
elif [ -f $str ]
    then
        echo "文件已经存在 ! [ $str ]"
elif [ ${str##*.} != "cpp" ]
    then
        echo "请检查文件类型 是否为cpp文件 [${str##*.}]"
else
    f;
    vi $str
fi

保存为 crcpp | chmod a+x crcpp |crcpp a.cpp

创建 cpp 脚本

原文:http://ayang.blog.51cto.com/4224455/1652897

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!