line 12: should be this: while(p) Your program gets segment violation when strtok() returns NULL.
>>I realize its probably overkill for my purpose so if anyone could point me to a simpler solution that would be appreciated too.
In C language that's about the best anyone can do.
Ancient Dragon
Retired & Loving It
30,046 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,342
> I am not sure if this is needed or not, but most CSV files have a header record, which is essentially the names of the columns separated by commas. If you are parsing an actual CSV file, you will need to take that into account also.
That may be true for some, but the vast majority of CSV files in use have no such thing. Unlike something like an XML file, CSV files have no way to tell you what they contain. The reading program must know what to expect when reading any CSV. Even the assumption that CSV is textual data, or fields separated by commas or tabs, and other stuff, is entirely that, assumption.
If you like I'll dig up an old CSV parser I wrote that can handle anything and port it to C for you. (Remember, it can read and write any CSV file, but, again, you must know what that CSV file contains for it to be useful!)
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
Hey there, if you're still interested, don't give up.
I wrote it originally in Object Pascal, and I used a number of very powerful container classes that don't exist in C (...obviously). So I've been coding a replacement for them also... (It's kind of boring actually...)
I should be done pretty soon. Once I give it some basic testing I'll wrap the whole thing up for you and respond here again.
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229