{"id":527,"date":"2016-11-08T14:00:41","date_gmt":"2016-11-08T14:00:41","guid":{"rendered":"http:\/\/mchmelar.cz\/?p=527"},"modified":"2019-12-16T23:02:12","modified_gmt":"2019-12-16T23:02:12","slug":"soubor-v-argumentu","status":"publish","type":"post","link":"https:\/\/kb.mchmelar.cz\/?p=527","title":{"rendered":"Soubor v argumentu"},"content":{"rendered":"<p>CSV soubor v argumentu<br \/>\n<a href=\"http:\/\/mchmelar.cz\/wp-content\/uploads\/2016\/11\/sd.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-532 alignleft\" src=\"http:\/\/mchmelar.cz\/wp-content\/uploads\/2016\/11\/sd.png\" alt=\"sd\" width=\"532\" height=\"25\"><\/a><\/p>\n<pre>#include <stdio.h>\n#define CELLS_MAX_LEN 100\nint csv_read_cell(FILE *db, char *cell)\n{\n  int c, i = 0;\n  while ((c = fgetc(db)) != EOF &amp;&amp; c != ',' &amp;&amp; c != '\\n' &amp;&amp; i &lt; CELLS_MAX_LEN-2)\n    cell[i++] = c;\n  cell[i] = '\\n';\n  cell[i+1] = '\\0';\n  return i;\n}\nint main(int argc, char *argv[]) {\n  char cell[CELLS_MAX_LEN];\n  if (argc != 2) {\n    printf(\"chybny pocet argumentu\\n\");\n    return 1;\n  }\n  FILE *csv = fopen(argv[1], \"r\");\n  if (csv == NULL) {\n    printf(\"chyba otevirani\\n\");\n    return 1;\n  }\n  int len = csv_read_cell(csv, cell);\n  while (len &gt; 0) {\n    fprintf(stderr, \"in while, len=%d\\n\", len);\n    printf(\"%s\", cell);\n    len = csv_read_cell(csv, cell);\n  }\n  fclose(csv);\n  return 0;\n}\n<\/stdio.h><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>CSV soubor v argumentu #include #define CELLS_MAX_LEN 100 int csv_read_cell(FILE *db, char *cell) { int c, i = 0; while ((c = fgetc(db)) != EOF &amp;&amp; c != &#8216;,&#8217; &amp;&amp; c != &#8216;\\n&#8217; &amp;&amp; i &lt; CELLS_MAX_LEN-2) cell[i++] = c; cell[i] = &#8216;\\n&#8217;; cell[i+1] = &#8216;\\0&#8217;; return i; } int main(int argc, char *argv[]) { char cell[CELLS_MAX_LEN]; if (argc !=&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"_links":{"self":[{"href":"https:\/\/kb.mchmelar.cz\/index.php?rest_route=\/wp\/v2\/posts\/527"}],"collection":[{"href":"https:\/\/kb.mchmelar.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kb.mchmelar.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kb.mchmelar.cz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.mchmelar.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=527"}],"version-history":[{"count":1,"href":"https:\/\/kb.mchmelar.cz\/index.php?rest_route=\/wp\/v2\/posts\/527\/revisions"}],"predecessor-version":[{"id":3008,"href":"https:\/\/kb.mchmelar.cz\/index.php?rest_route=\/wp\/v2\/posts\/527\/revisions\/3008"}],"wp:attachment":[{"href":"https:\/\/kb.mchmelar.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kb.mchmelar.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kb.mchmelar.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}