4

I am a seeking to make a UI for my C school project and I am proficient in HTML CSS Js JQuery.

anybody know any way that I can 'embed' C in HTML?

4

4 回答 4

3

You can write CGI scripts in any language, including C.

于 2013-11-15T08:08:55.367 回答
3

You can include or embed C code in an HTML document, but it will not do anything; it will taken just as text data.

There is no support in browsers for using C as client-side scripting language. Theoretically, you could write an interpreter for C (or a subset of C) in JavaScript. Or even a browser that has native C support...

On the more practical side, you can use C as server-side programming language. It would then normally be used via CGI (Common Gateway Interface), but then you need support for this on the server you use. And it would not be particularly efficient especially for implementing a UI, since processing any user action would require an HTTP request and would launch a new process on the server, running the compiled C program, which would then send the result back to the browser.

So you probably don’t want to use C in this context. But if you still consider it, check my dusty old page Getting Started with CGI Programming in C.

于 2013-11-15T09:11:11.817 回答
1

You can compile portable C code into web assembly, then embed it into HTML.

A compiler that compiles into web assembly: https://emscripten.org/docs/introducing_emscripten/about_emscripten.html

web assembly: https://webassembly.org/

于 2020-12-25T05:03:37.013 回答
0

You can use PHP's shell_exec() like this:

<!DOCTYPE html>
<body>
    <?php shell_exec("python your_file_here.py") ?>
</body>
于 2021-11-30T12:17:55.550 回答