Hello World Example

Description

This is a basic Hello World program. It shows that WebC starts in HTML mode and then switches to C mode when it hits a <?wc . It continues in C mode until it hits the closing ?>.

You can also see the generated C code. The C code writes a function named Page_Filename. Where Filename is the name of the .wc file. The C code then calls wcecho() function (which you must provide) to write the string out to the web server. And finally the C page function is closed (}).

WebC Code

<!DOCTYPE HTML>
<html>
   <head>
       <title>Hello World</title>
   </head>
   <body>
       <?wc wcecho("Hello World"); ?>
   </body>
</html> 

C Code

#include "WCWebAPI.h"

void Page_HelloWorld(void)
{
    wcecho("<!DOCTYPE HTML>\n"
        "<html>\n"
        "   <head>\n"
        "       <title>Hello World</title>\n"
        "   </head>\n"
        "   <body>\n");
    wcecho("Hello World");
    wcecho("   </body>\n"
        "</html>\n");
}

Output

<!DOCTYPE HTML>
<html>
   <head>
       <title>Hello World</title>
   </head>
   <body>
       Hello World
   </body>
</html>