a.txt"); system("ls / >>a.txt"); } " />
红联Linux门户
Linux帮助

echo的小问题,求解

发布时间:2011-08-12 11:49:06来源:红联作者:四维帝国
我想要在a.txt文本文件中加入一句话"以下是...,你懂得...",然后再将根目录下的文件名列表输入到该a.txt文本文件中,结果出错啦...求解阿...该如何使用echo呢???:0wl;l1
#include
int main()
{
system("echo "以下是..,你懂得... ">a.txt");
system("ls / >>a.txt");
}


错误提示:
l.c: In function ‘main’:
l.c:4:2: error: stray ‘\344’ in program
l.c:4:2: error: stray ‘\273’ in program
l.c:4:2: error: stray ‘\245’ in program
l.c:4:2: error: stray ‘\344’ in program
l.c:4:2: error: stray ‘\270’ in program
l.c:4:2: error: stray ‘\213’ in program
l.c:4:2: error: stray ‘\346’ in program
l.c:4:2: error: stray ‘\230’ in program
l.c:4:2: error: stray ‘\257’ in program
l.c:4:26: error: expected identifier before ‘.’ token
l.c:4:26: error: stray ‘\344’ in program
l.c:4:26: error: stray ‘\275’ in program
l.c:4:26: error: stray ‘\240’ in program
l.c:4:26: error: stray ‘\346’ in program
l.c:4:26: error: stray ‘\207’ in program
l.c:4:26: error: stray ‘\202’ in program
l.c:4:26: error: stray ‘\345’ in program
l.c:4:26: error: stray ‘\276’ in program
l.c:4:26: error: stray ‘\227’ in program
文章评论

共有 8 条评论

  1. D调漫步 于 2011-08-15 13:56:09发表:

    路过

  2. _forever_ 于 2011-08-15 12:12:29发表:

    似乎
    echo as
    echo “as”
    执行效果没什么区别
    echo /“as/” 才输出“”
    #include
    int main()
    {
    system("echo \\\"以下是..,你懂得...\\\">a.txt");
    system("ls / >>a.txt");
    }

  3. _forever_ 于 2011-08-15 11:55:34发表:

    "
    似乎要用转义符(\)的吧

  4. peipei20140 于 2011-08-14 16:15:31发表:

    这种问题真不知道该怎么回答,就不能把问题描述清楚吗?

  5. yiku123 于 2011-08-13 16:26:32发表:

    楼主要套件那句话很个性

  6. 年年年 于 2011-08-13 15:31:25发表:

    #include
    int main()
    {
    system("echo \"以下是..,你懂得... \">a\.txt");
    system("ls / >>a\.txt");
    }
    linux C我不大懂。。但是perl里面也有system。双引号里面的一些符号需要转义。不知是否正确,你试试看吧

  7. jinger7281 于 2011-08-12 23:50:50发表:

    #include
    int main()
    {
    system("echo "以下是..,你懂得... ">a.txt");
    system("ls / >>a.txt");
    }

    你C没学好啊,再说system调用你也没明白什么用法,有点急功近利了
    #include
    #include
    int main(){
    system("echo 以下是...,你懂得 1>a.txt");
    system("ls / 1>a.txt");
    return 0;
    }
    记住函数前边如果声明了返回类型的时候一定要return一下!

  8. yanyongkg 于 2011-08-12 18:29:34发表:

    看到这种不清不白的提问,很是无语。。。