Allow me to make some adjustments.
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <cstdlib>
using namespace std;
class ship
{
char Name[256];
vector<string> inventory;
public:
void setName(char *nam)
{
strcpy(Name, nam);
cout << Name;
}
void addToInventory(string frt, string sec, string thir)
{
inventory.push_back (frt);
inventory.push_back (sec);
inventory.push_back (thir);
cout << inventory[0]; //Is this really needed?
}
void listInventory()
{
for(int i=0;i<inventory.size();i++)
{
cout << inventory[i];
}
}
};
int main()
{
char shipcall[256];
ship player;
cout << "welcome to space \n";
string frt = "Credits";
string sec = "cargo";
string thir = "Armaments";
cout << " Name your ship\n";
cin.get(shipcall,156);
player.setName(shipcall);
player.addToInventory(frt, sec,thir);
player.listInventory();
system ("pause");
return 0;
}