I have to read from a .txt file which has info as such,

1:4:7 and so on.

3 Columns, lots of rows.

How can i read each column for example 10 to x, 5 to y, 23 to z.

Why not use strtok function to split each row, using ' : ' as separator?

Well, there seems to be something wrong.

it gives error here

void reader()
	string holdInput ="";
	char *tokenizedInput;
		cout<<" opened succesfully"<<endl;
		cout<<" epic fail"<<endl;
	while (! input.eof() )
                  getline (input,holdInput);
	tokenizedInput = strtok (holdInput," :");

Do i have to do something after tokenizing to seperate the values.

As you may have noticed, i am relatively new to C++.

I think its erroring because its expecting a cstr not a std::string


strtok(holdInput.cstr(), " :");

cannot convert parameter 1 from const char* to char*

cannot convert parameter 1 from const char* to char*

Is there some other way where i can read the info from a file and tokenize each line to 3 different values. In java it is deadly simple but i dont understand why its such a burden in c++

Glad to be of help :)

I still think there should be some function which gets number upto : then puts it in x, then reads on and gets the next up to : and puts it in to y, etc...

Take a look at this thread:http://www.daniweb.com/forums/post246417.html#post246417
Substitute ':' for ',' in the delimiter of the second getline call and you should have what you need (minus fixing it to work with your arrays,etc). You can use an N x 3 array for holding the strings or just do your parsing for ints on the fly. See this for more info on the stringstream >> operator.