【发布时间】:2013-11-12 02:24:58
【问题描述】:
这是我尝试使用的代码:
//Have the user input the file name that they want to read
cout << "Enter name of file: ";
cin >> recordName;
//Create the object that the file will be read into
ifstream records;
//Open file for reading
records.open(recordName);
文本文件只是人员姓名和工资率的列表。代码不会按原样编译,我不知道为什么它不会将字符串读取为文本文件名。
【问题讨论】:
-
你遇到了什么错误?
-
如果这是整个代码,那么您缺少包含几个标题,您需要一个
main函数。 -
总是发布编译器错误,所以我们不需要猜测。
-
这是你的代码,还是你也在某个地方找到的?
-
“代码不会编译”不是问题描述。错误信息(和消息)就在您的屏幕上(我们无法从这里看到)。绝对没有任何借口不将其包含在您的帖子中。请edit 这样做。如果您希望我们为您提供帮助,您需要提供我们可以使用的信息。