您可以使用C 从在线编译器(repl.it)打开文件吗?

Can you open a file from a an online compiler (repl.it) using C++

本文关键字:it 文件 repl 可以使 编译器 在线      更新时间:2023-10-16

我想看看是否可以打开文件,使用在线编译器写入并保存它。我之所以使用它的原因是因为我使用的是一个很难运行Xcode或CodeBlocks的MacBook。我要打开的文件保存在我的桌面上的文件名" image.ppm"下。这是代码:

#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>
using namespace std;
int main() 
{  
  char filename[100];
  ifstream input;
  cin.getline(filename, 100);
  input.open(filename);
} 

当我运行时,什么也不会发生,我认为这是因为在线编译器看不到image.ppm文件

是否允许您读/写文件是无关紧要的;当然,它无法在您的计算机上看到文件。