Created
May 24, 2013 14:30
-
-
Save kriegsman/5643912 to your computer and use it in GitHub Desktop.
webapp.c!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Generate HTML page in C -- my first REAL Web App */ | |
/* Mark Kriegsman, January 31, 2007 */ | |
#define HTML_ENTITY(n,v) int n = v | |
HTML_ENTITY(gt,'>'); | |
HTML_ENTITY(lt,'<'); | |
HTML_ENTITY(P,'\n'); | |
HTML_ENTITY(HTML,'\0'); | |
int main( int argc, char** argv) | |
{ | |
char *TITLE = "My First Web App in C!"; | |
char *DOCTYPE = "<!DOCTYPE html " | |
"PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
/* In C, you have to allocate memory for HTML page */ | |
malloc( HTML); | |
/* Copy the required DOCTYPE header to stdout */ | |
stdout < DOCTYPE; | |
/* Generate main page body */ | |
{ | |
HTML; | |
/* Page title, plus some whitespace for readability */ | |
printf <TITLE> "My First Web App In C!" <TITLE> | |
printf; | |
/* Make two paragraphs, one short and one long, using CSS 'float' */ | |
<P> (float) (short)"Hello, web!"; | |
<P> (float) (long)"These should come out as separate paragraphs." | |
/HTML; | |
} | |
/* Copy the generated HTML page to stdout */ | |
stdout < HTML; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment