我按照Webassembly入门教程http://webassembly.org/getting-started/developers-guide/
它运作良好,并显示"你好,世界!" 浏览器中的消息.
然后我尝试了一个小的C++代码,打开一个文本文件并在读取文件后进行计算(10*20).
emcc编译文件就好了,没有错误.
但是当我通过运行emrun通过HTTP提供文件时,它无法打开文件.
这是我在emrun Web控制台中看到的:
Unable to open file
200
Run Code Online (Sandbox Code Playgroud)
从本地磁盘打开文件有什么限制吗?
[thiago@terra hello]$ cat pfile.cpp
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string line;
int a, b, c;
ifstream myfile("test.txt");
if (myfile.is_open()) {
while (getline (myfile, line)) {
cout << line << endl;
}
myfile.close();
}
else cout << "Unable to open file" << endl;
a = 10;
b = 20;
c = a * b;
cout << c << endl; …Run Code Online (Sandbox Code Playgroud)