Dose anyone have any suggestions on how I can get it to display the whole set of strings??
#include <iostream>
#include <string>
using namespace std;
int main()
{
int i; i = 0;
int k; k =-1;
string name[5][80] = { "swordmen",
"archers",
"spearmen",
"macemen",
"horsemen",
};
int unitstatslife[5] = { 120, 55, 85, 45, 230, };
int unitstatsattack[5] = { 12, 5, 7, 6, 14, };
for(i; i < 5; i++, k++)
{
cout << name[k][80] << " Life: ";
cout << unitstatslife[i] << " Attack: ";
cout << unitstatsattack[i] << endl;
}
cout << name[-1][80];
// Specific Army, discover what units are pressant.
//ie 1 = swordmen
// units
// each one needs an ID, this is then what is stored in the Armies arry now, not the units name.
// a number identifying the unit type is then stored in the unit array. This uit array also contains all the units attributes for combat..
// opens the file called "swordmen" gets the first number as the id.
// if
const int max_units = 10;
int NationalUnits[max_units][2] =
{ 1, 1,
1, 2,
1, 2,
}; // army 1 unit type 1 = "Swordmen";
// army 1 unit type 2 = "Archers";
// army 1 unit type 2 = "Archers";
int x;
cout << endl << "Enter X: ";
cin >> x;
int j;
j = x;
if(x >=1)
{
cout << NationalUnits[x-2][1] << " ",
cout << name[x-2][80] << " Life: ",
cout << unitstatslife[j-1] << " Attack: ",
cout << unitstatsattack[j-1] << endl;
}
else {
cout << "Incorrect Input please try again: ",
cin >> x;
}
// to view output
cin >> x;
return 0;
};

New Topic/Question
Reply



MultiQuote







|