Oh. Forgot to mention. The csv_field() function above handles even embedded NUL bytes correctly. (You could easily amend the function to replace them with another value, or skip them altogether.)
...
Type: Posts; User: Nominal Animal
Oh. Forgot to mention. The csv_field() function above handles even embedded NUL bytes correctly. (You could easily amend the function to replace them with another value, or skip them altogether.)
...
I'm personally way too paranoid for that :)
Hm. I fully concur.
And, you have an even stronger point that I do. Most of the readers of this thread are newbies, especially if they're having...
Assuming there are no bugs lurking in it, it does. For example, given input
First, Second, Third
"""Bah,"" she said.", pretty"robust, "multiple
lines
are not a problem"
foo" bar "baz
the...
I understand your point, and agree with your reasoning.
I just don't think you are considering the full picture here.
First, it was just a coincidence that the three cases happened to coalesce...
Since reading CSV in C seems to be such a frequent question, I thought I'd post a simple and robust implementation:
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include...
Right; fixed. It's defined in POSIX.1-2008 instead.
Or, if you have a C library that supports POSIX.1-2008, use getline():
#define _POSIX_C_SOURCE 200809L
#include <stdio.h>
int scan(FILE *const input, const char *const substring[], const...