CSV to HTML translation: Difference between revisions
Content added Content deleted
(→{{header|C}}: Argh, bad/missing terminating tags are not obvious in a section preview.) |
m (→{{header|C}}: some linebreaks) |
||
Line 232:
=={{header|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("<"); break;
Line 260 ⟶ 258:
}
}
puts("</td></tr>\n</table>");
return 0;
Line 270 ⟶ 268:
$ ./csv</pre>
<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><angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry></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++}}==
|