ok, well, looking at the other posts in this forum I'm the least experienced here, hope you all don't mind me asking these questions.
Now, I've been learning about arrays the past few days and have no problems getting text to display from one, but, how do you take text from a 'char' array by inputting a number?
Here is what I'm trying to do:
Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const int months[]={'j','f','m','a','m','j','j','a','s','o','n','d'};
const int days[]={31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int kbi=0, int kbin=0, int count=0;
cout << "Enter date in # format (ie, 1,2,3...12): ";
cin >> kbi;
kbin=(kbi-1);
for(;kbin=kbin
{
cout << "The month " << months[kbin] << " has "
<< days[kbin] << " days in it.";
system("pause");
return 0;
}
//kill
system("pause");
return 0;
}
For some reason when I enter 1 for 'j' January I get "The month 106 has 31 days in it", umm, that's a far cry from the 31 it's supposed to have.
I heard of a static_cast a few days back, is that needed here?
Thanks for your help (and previous help)
Rob
[Note: I'm not comparing c++ to batch this time lol]