使用系统命令写入文件
Write a file using System Command
我正在尝试使用系统命令创建文件,但由于某种原因它不起作用。它只是回显命令。
system("echo 'Hello2222, world.' >foo2.txt");
Hello2222, world. >foo2.txt
当我在CMD中运行回显命令时,文件被创建。
请注意 system
的文档说
On Windows, system does not use a shell and there is a separate
function shell which passes command lines to a shell.
shell("echo 'Hello2222, world.' >foo2.txt")
会做你想做的。
我正在尝试使用系统命令创建文件,但由于某种原因它不起作用。它只是回显命令。
system("echo 'Hello2222, world.' >foo2.txt");
Hello2222, world. >foo2.txt
当我在CMD中运行回显命令时,文件被创建。
请注意 system
的文档说
On Windows, system does not use a shell and there is a separate function shell which passes command lines to a shell.
shell("echo 'Hello2222, world.' >foo2.txt")
会做你想做的。