Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a problem. If I use the
tag, it doesn't work: <pre><code class="c"> printf("<h1>HI</h1>"); </code>
it displays on the page:printf("<h1>HI</h1>");
How can I fix this?

If you're trying to use "C functions", then <code> is just an html tag that is used to set off any "code" in a fixed font for formatting purposes... it doesn't parse / compile C code.
Or do you mean something else?

You'd need to compile as a binary and upload into the cgi-bin folder... your host would also have to allow execution.
#include <stdio.h> int main(void) { printf("Content-type: text/html\n\n"); // always needed printf("<html>\n"); printf("<head>\n"); printf("head elements\n"); printf("</head>\n"); printf("<body>\n"); printf("body elements\n"); printf("</body>\n"); printf("</html>\n"); return (0); }If your host allows for php, then it has similar functions to C including printf.
HTH

You'd need a C / C++ compiler and create an executable; here's gcc from gnu or you can mill over others here.
Here's a resource with source code and a few tips that may also help. However, if you're just using a few functions, then you really may want to consider a server side scripting language instead...
Good luck.

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |