emscripten-core / emscripten-core/emscripten
How use fwrite in Wasm
Open
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
In main.cpp :
`#include
#include
int main() {
FILE *fh;
fh = fopen("a.txt", "wb");
if (!fh) exit(1);
fclose(fh);
fh = fopen("a.txt", "rb");
if (!fh) exit(1);
char data[] = "foobar";
size_t written = fwrite(data, 1, sizeof(data), fh);
printf("written=%zu\n", written);
}`
And compile it as:
emcc main.c -o main.html --preload-file a.txt
finally i run the html , why the a.txt is empty, how to use the fwrite, write something to the file?
Contributor guide
Assessment
This issue has not been assessed yet.