I want to add 2 vectors to print out so that there on the same line. What I am trying to make is an inventory system that will use 2 vectors to keep the pounds of the item and list the 2 vectors on one line.
(I am using Microsoft Visual C++ 2010 Express)
Like this:
0. empty 0
1. empty 0
2. empty 0
ect...
Right now it looks like this:
0. empty
0. 0
The code:
I am new, I use this type of code because its the code i know the best to use in C++ in my class.
(I am using Microsoft Visual C++ 2010 Express)
Like this:
0. empty 0
1. empty 0
2. empty 0
ect...
Right now it looks like this:
0. empty
0. 0
The code:
Code:
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <cmath>
using namespace std;
int main()
{
vector<string> inv;
vector<int> pou;
int num;
int del;
int asdf;
string name;
inv.push_back("Empty");
pou.push_back(0);
vector<string>::const_iterator iter;
vector<int>::const_iterator iter2;
vector<string>::iterator myIterator;
cout << "\t\t\t\t*Inventory Wight*\n\n";
cout << "Your inventory and pounds:\n";
asdf = -1;
for (iter = inv.begin(); iter != inv.end(); ++iter)
{
++asdf;
cout << asdf << ". " << *iter << endl;
}
asdf = -1;
for (iter2 = pou.begin(); iter2 != pou.end(); ++iter2)
{
++asdf;
cout << asdf << ". " << *iter2 << endl;
}
system("pause");
return 0;
}
I am new, I use this type of code because its the code i know the best to use in C++ in my class.
Comment