web_2024/R1.02/tp/tp1/src/csv2html.c

26 lines
468 B
C
Raw Normal View History

2024-11-15 12:31:42 +01:00
#include <stdio.h>
/* csv2html < file.csv > file.html */
int main(int argc, char *argv[])
{
int s;
printf("<table>\n<tr><td>");
while ((s = getchar()) != EOF) {
switch(s) {
case '\n': printf("</td></tr>\n<tr><td>"); break;
case ';': printf("</td><td>"); break;
case '<': printf("&lt;"); break;
case '>': printf("&gt;"); break;
case '&': printf("&amp;"); break;
default: putchar(s);
}
}
puts("</td></tr>\n</table>");
return 0;
}