Updated by Andrey Kamaev almost 13 years ago

The function @read_csv@ read_csv crashes when reading data who only has one column.

Here is the code:

<pre><code class="cpp">
@ // read the first line and determine the number of variables

std::vector<char> _buf(M);

char* buf = &_buf[0];

if( !fgets_chomp( buf, M, file ))

{

fclose(file);

return -1;

}

for( ptr = buf; *ptr != '\0'; ptr++ )

cols_count += (*ptr == delimiter);



if ( cols_count == 0)

{

fclose(file);

return -1;

}
cols_count++;
</code></pre>

cols_count++;@


If the values have no commas before the newline it crashes in @if ( cols_count == 0)@ if they have a comma before the newline it crashes when you use @get_values()@ get_values() (Access Violation).

Back