Read the Manual for the installation guidelines.
git clone https://github.com/itspacedev/c_wasm.git
npm install
emcc hello_world.c -o index.html \
-sEXPORTED_FUNCTIONS=_intSqrt,_addTwoNumbers,_returnString,_getStringLength \
-sEXPORTED_RUNTIME_METHODS=ccall,cwrap,stringToNewUTF8,UTF8ToString
http-server .
Open the main.html
file in a browser
Open in Chrome: http://127.0.0.1:8080/main.html (IP:PORT may be different for you)
You should see the following output:
#1. Get integer square root
intSqrt(33) = 5
#2. Add two numbers
addTwoNumbers(4, 91) = 95
#3. Return a string from C
returnString() = This is the Wallet (type string)
#4. Get string length
getStringLength("This is my long string") = 22