CSV to HTML translation: Difference between revisions

m
→‎{{header|C}}: some linebreaks
(→‎{{header|C}}: Argh, bad/missing terminating tags are not obvious in a section preview.)
m (→‎{{header|C}}: some linebreaks)
Line 232:
 
=={{header|C}}==
 
{{lines too long|C}}
 
<lang c>#include <stdio.h>
Line 249 ⟶ 247:
{
char *s = input;
printf("<table>\n<tr><td>");
for (s = input; *s; s++) {
switch(*s) {
case '\n': printf("</td></tr>\n<tr><td>"); break;
case ',': printf("</td><td>"); break;
case '<': printf("&lt;"); break;
Line 260 ⟶ 258:
}
}
puts("</td></tr>\n</table>");
 
return 0;
Line 270 ⟶ 268:
$ ./csv</pre>
 
<lang html5><table>
<lang html5><table><tr><td>Character</td><td>Speech</td></tr><tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr><tr><td>Brians mother</td><td>&lt;angry&gt;Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!&lt;/angry&gt;</td></tr><tr><td>The multitude</td><td>Who are you?</td></tr><tr><td>Brians mother</td><td>I'm his mother; that's who!</td></tr><tr><td>The multitude</td><td>Behold his mother! Behold his mother!</td></tr></table></lang>
<tr><td>Character</td><td>Speech</td></tr>
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr>
<tr><td>Brians mother</td><td>&lt;angry&gt;Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!&lt;/angry&gt;</td></tr>
<tr><td>The multitude</td><td>Who are you?</td></tr>
<tr><td>Brians mother</td><td>I'm his mother; that's who!</td></tr>
<tr><td>The multitude</td><td>Behold his mother! Behold his mother!</td></tr>
</table></lang>
 
=={{header|C++}}==