26 lines
503 B
C
26 lines
503 B
C
// https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/doc/build_wasm_app.md#user-content-build-wasm-applications-with-wasi-sdk
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
char *buf;
|
|
|
|
printf("Hello world!\n");
|
|
printf("Got %d args!\n", argc);
|
|
|
|
buf = malloc(1024);
|
|
if (!buf) {
|
|
printf("malloc buf failed\n");
|
|
return -1;
|
|
}
|
|
|
|
printf("buf ptr: %p\n", buf);
|
|
|
|
sprintf(buf, "%s", "1234\n");
|
|
printf("buf: %s", buf);
|
|
|
|
free(buf);
|
|
return 0;
|
|
}
|