且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在C ++中从文件中读取和执行命令

更新时间:2023-11-11 20:41:46

您可能希望在尝试之前练习编写简单的C ++程序。 您发布的代码有几个基本问​​题。

You might want to practice writing simple C++ programs before attempt this.  The code you posted has several fundamental problems.

标准标题应该用尖括号(<和>)括起来,而不是用引号括起来。

Standard headers should be enclosed in angle brackets (< and >), not in quotes.

您不使用conio.h或iomanip中的任何内容。 你为什么要包含它们?

You don't use anything from conio.h or iomanip.  Why did you include them?

你打开outfile但从不写它。

You open outfile but never write to it.

你声明输入文件两次。

您尝试使用名称为零字符(一个构造为空的字符串)打开文件。

You attempt to open a file with a name that has zero characters (a string that was constructed as empty).

您永远不会从输入文件中读取。

You never read from inputfile.

检查argc值的目的是什么?

What is the purpose of checking the value of argc?

函数system()接受实际命令,而不是包含命令的文件名。

The function system() takes an actual command, not the name of a file that contains the command.

你缺少至少一个右括号(})。

You are missing at least one closing brace (}).