vector push back issue

Hi guys, i'm trying to write a code, and i am stuck with an issue.
I have a vector, and i need to write it's elements in this format:

Index Value (these 2 are separated through a tab), and under them i have to write the vector's elements using the push.back method. I mean, i know how to write a push.back but i'm stuck in writing it as "Index Value".
Can anyone help me? I really don't know how to solve this..thanx!
Perhaps define a struct
1
2
3
4
5
6
7
8
9
10
11
struct item {
    int index;
    double value;
};

vector<item> vect;

item a;
a.index = 1;
a.value = 2.34;
vect.push_back(a);
Or is it just as simple as
1
2
for (int i = 0; i < myVector.size(); ++i)
    std::cout << i << ' ' << myVector[i] << '\n';

?
Topic archived. No new replies allowed.