generated from loic/c-template
feat: Colleen.c
This commit is contained in:
parent
4f5319860c
commit
dbdf78778c
1 changed files with 34 additions and 0 deletions
|
|
@ -1,6 +1,40 @@
|
|||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void
|
||||
foo(void)
|
||||
{
|
||||
write(2, "Hello world!\n", 13);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
// One of the comments must be present in the main function
|
||||
char *src = "#include <stddef.h>\n#include <unistd.h>\n\nvoid\nfoo(void)\n{\n\twrite(2, \"Hello world!\\n\", 13);\n}\n\nint\nmain(void)\n{\n\t// One of the comments must be present in the main function\n\tchar\t*src = \"$\";\n\tfor (size_t i = 0; src[i]; ++i)\n\t{\n\t\tif (36 == src[i])\n\t\t{\n\t\t\tfor (size_t j = 0; src[j]; ++j)\n\t\t\t{\n\t\t\t\tswitch (src[j])\n\t\t\t\t{\n\t\t\t\t\tcase 10:\twrite(1, \"\\\\n\", 2); break;\n\t\t\t\t\tcase 9:\t\twrite(1, \"\\\\t\", 2); break;\n\t\t\t\t\tcase '\\\\':\twrite(1, \"\\\\\\\\\", 2); break;\n\t\t\t\t\tcase '\"':\twrite(1, \"\\\\\\\"\", 2); break;\n\t\t\t\t\tdefault:\twrite(1, &src[j], 1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\twrite(1, &src[i], 1);\n\t\t}\n\t}\n\n\tfoo();\n\treturn 0;\n}\n// One of the comments must be present outside of your program.\n";
|
||||
for (size_t i = 0; src[i]; ++i)
|
||||
{
|
||||
if (36 == src[i])
|
||||
{
|
||||
for (size_t j = 0; src[j]; ++j)
|
||||
{
|
||||
switch (src[j])
|
||||
{
|
||||
case 10: write(1, "\\n", 2); break;
|
||||
case 9: write(1, "\\t", 2); break;
|
||||
case '\\': write(1, "\\\\", 2); break;
|
||||
case '"': write(1, "\\\"", 2); break;
|
||||
default: write(1, &src[j], 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
write(1, &src[i], 1);
|
||||
}
|
||||
}
|
||||
|
||||
foo();
|
||||
return 0;
|
||||
}
|
||||
// One of the comments must be present outside of your program.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue