Hi all,
Can you please tell me how to read .csv files in C++/VC++??
I converted my excel files to .csv files in order to make reading easy.

Need help regarding the code.

Thanks
Rishi.

From what I can glean from wikipedia a csv file is just like a normal text file. For reading and writing file info click here

Member Avatar for iamthwee

I presume each word separated by a comma, will represent a variable in a class declaration.

For example,
.csv file

Sugar, Big jugs, slightly kooky, 18,

Might be represented as

class Hoe
{
 string name;
 string description;
 string intelligence;
 int age;
}

You can use the comma as a delimiter to parse the string into tokens and assign them to your class variables.

Also, regarding Sturm's link to reading files, might be slightly dubious due to !myfile.EOF. Although I just read it briefly so it might be ok. That website is normally good.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.