C Example: Delimiter Splitter: keep empty fields when splitting and joining
A CSV line parser: splits a record on commas while preserving empty fields created by consecutive delimiters, then re-joins the fields with another delimiter. The hand-written scanner (instead of strtok) handles empty and trailing fields correctly, which matters for real config and table rows.
🖥 Run OnlineGCC 10.2 · C11 standard · click ▶ to run · Copy code
🖨 Reference OutputMatches the online run in a standard C11 environment
record: alpha,beta,,gamma,delta fields: 5 [0] alpha [1] beta [2] (empty) [3] gamma [4] delta joined: alpha | beta | | gamma | delta
🧩 Keep Learning