-
Notifications
You must be signed in to change notification settings - Fork 3
Snprintf
Chung Leong edited this page Jul 26, 2024
·
7 revisions
This example will show you how you can use snprintf()
, a function from the C standard library,
in Javascript. "Why on earth would I want to do that?" might be your immediate question. The
answer is "because it's there". This example is meant to demonstrate the power of Zig, how it
allows you to do things that you can't do in C. It's meant to show how, thanks to the Zig compiler,
you can employ C code in situations where you'd never imagine.
Thie example comes in two parts. In the first part, we'd be using snprintf()
(and friends) in
Node.js. The actual function in GNU libc or msvcrt would actually be called from JavaScript.
In the second part, we'd create a React app that uses libc in WebAssembly.