Guys,
In below code after reading string values from vector , I can have output like("VarID","flag","count")

for(int i=0; i < v.size(); i++){
 cout<<v[i]<<endl;
}

All are (varID,flag and count)are string literal , now i need to populate the structre with this string literal.
where VarID = int,flag=bool, count=Int. Can anybody suggest regarding this how this converson will take place as i am new to STL.

Recommended Answers

All 5 Replies

please explain what you want.
Your explanations are cryptic!

Hi,
I am reading this values from map and pushing into the vector. Now inside the vector I can't perform conversion for this parameter like atoi(v[0]),atof(v[1]) etc. Could you let me know what is the best way to convert this string inside the vector or any other container can also solve this problem. It doesn't seems to be possible in vector because vector only supports string types.so i thought can we from the structure from the vector.

You need to describe the whole situation man, what is in the map, the data types of key and value, etc. Be clear!

Hi,

Here is the details.
(1)both key value are string , like map<string,string> and only value part i am pushing back in to the vector as i explained in my original post.
(2)so now vector is having only string values , so now these value needs to be converted in dif-2 data types. I hope it is suffice.

There are basically 2 main methods that work very well. The faster, is the old sprintf. The easier one is stringstream.

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.