【发布时间】:2016-01-24 05:39:58
【问题描述】:
假设我的主目录中有 temp.txt,我想对这个文件中的所有数据进行排序,并将所有排序后的数据写入另一个名为 hello.txt 的文件中。这是我尝试过的代码(编程 c):
#include <stdio.h>
#include <stdlib.h>
int main(int agrc,char *argv[]){
char *argv1[]={"sort","temp.txt",">", "hello.txt",NULL};
printf("hello I will sort a file\n");
execvp(argv1[0],argv1);
}
这是我的程序,终端总是给我一条错误消息,即
hello I will sort a file
sort: cannot read: >: No such file or directory
谁能告诉我我的代码有什么问题?有人可以告诉我如何解决吗?感谢您的帮助!
【问题讨论】: