{"id":207,"date":"2016-07-04T23:11:02","date_gmt":"2016-07-04T22:11:02","guid":{"rendered":"https:\/\/solidt.eu\/blog\/?p=207"},"modified":"2016-07-04T23:11:02","modified_gmt":"2016-07-04T22:11:02","slug":"c-simple-parsing","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/c-simple-parsing\/","title":{"rendered":"C Simple parsing"},"content":{"rendered":"<pre lang=\"c\" class=\"\">#include \r\n#include \r\n\r\n\r\nint main(int argc, char** argv)\r\n{\r\n    FILE* handle = NULL;\r\n\r\n    if (argc == 2)\r\n        handle = fopen(argv[1], \"r\"); \/\/ r+b \/\/ read-write binary\r\n    else\r\n        handle = stdin;\r\n\r\n    if (handle == NULL)\r\n        return 1; \/\/ Could not open file\r\n\r\n    printf(\"\/$ \");\r\n\r\n    int c = 0;\r\n\r\n    char command_line[255];\r\n    char command_char[2];\r\n\r\n    command_line[0] = 0;\r\n\r\n    while(!feof(handle))\r\n    {\r\n        c = fgetc(handle);\r\n\r\n        \/\/fputc(c, stdout);\r\n\r\n        if (c != 0)\r\n        {\r\n            \/\/printf(\"%d \", c);\r\n            command_char[0] = c;\r\n            command_char[1] = 0;\r\n            strcat(command_line, command_char);\r\n        }\r\n\r\n        if (c == '\\n')\r\n        {\r\n            \/\/printf(\"%s\", command_line);\r\n            system(command_line);\r\n            printf(\"\/$ \");\r\n\r\n            command_line[0] = 0;\r\n        }\r\n    }\r\n\r\n    fclose(handle);\r\n\r\n    return 0;\r\n}\r\n\r\n\/\/fflush(stdout);\r\n\/\/FILE* handle = tmpfile();\r\n\/\/(c = fgetc(handle)) != EOF\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#include #include int main(int argc, char** argv) { FILE* handle = NULL; if (argc == 2) handle = fopen(argv[1], &#8220;r&#8221;); \/\/ r+b \/\/ read-write binary else handle = stdin; if (handle == NULL) return 1; \/\/ Could not open file printf(&#8220;\/$ &#8220;); int c = 0; char command_line[255]; char command_char[2]; command_line[0] = 0; while(!feof(handle)) { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-207","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=207"}],"version-history":[{"count":2,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/207\/revisions"}],"predecessor-version":[{"id":349,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/207\/revisions\/349"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}