Arrays

L

Latina

Hi, I have a string array, which there are the months.
If the user enters a number which is stored in an int variable
'month'.
How I can compare the value stored in the variable 'month' to the
string, to see if it is the same month.
I was thinking on comparing the index of the array with the value
stored in the variable 'month'.
But I don't know how to do it.
Can some one help me with that?
Thanks
 
A

Alf P. Steinbach

* Latina:
Hi, I have a string array, which there are the months.
If the user enters a number which is stored in an int variable
'month'.
How I can compare the value stored in the variable 'month' to the
string, to see if it is the same month.
I was thinking on comparing the index of the array with the value
stored in the variable 'month'.

Presumably the array contains the month names in order.

Then there's no need to compare anything, and it's meaningless to "see
if it is the same month".

The user's entered month number is directly (or +/- 1) the array index
of the corresponding month name.


Cheers, & hth.,

- Alf
 
L

Latina

* Latina:


Presumably the array contains the month names in order.

Then there's no need to compare anything, and it's meaningless to "see
if it is the same month".

The user's entered month number is directly (or +/- 1) the array index
of the corresponding month name.

Cheers, & hth.,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Ok, Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,197
Messages
2,571,040
Members
47,634
Latest member
RonnyBoelk

Latest Threads

Top