iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
What language are we using? c or c++?
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
Ok then, you can just do this:
1. Read in the cvs file.
2. Parse the data using the comma as a delimiter.
Which part are you stuck on?
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
If I showed you how to tokenise a string rather than a char array would that be ok?
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
>> can u give send me some code how to seperate the contents from commas.
That nice convenient class I posted that does exactly what you asked for must not have been what you really wanted. Why are you using char arrays anyway? How archaic!
he/she prolly doesn't even know what a class is.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
There's no point worrying about classes here. It will prolly just confuse you. Especially if you had to ask how it may be used with main. And don't forget, you have to incorporate this into an MFC application! Things could get ugly if you don't know what you're doing.
So here's a simple example:
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
int main()
{
string tmp = "What,the,hell,are,you,say,in,mo,fo";
vector <string> array;
string token;
istringstream iss(tmp);
while ( getline(iss, token, ',') )
{
array.push_back(token);
cout << token <<endl;
}
cin.get();
}
If you're dead set on using char arrays this may also be of use:- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1061423302&id=1044780608
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439