I think one issue here is there is a presumption of a certain knowledge level of C/C++.
The only programming language I know which remotely resembles C/C++ is PHP.
In PHP the only difference between using a string or a number is to enclose the string in quotes viz.
$fruit = array("apple", "orange", "banana", "pear");
if (in_array("pear", $fruit)) {
.... do something....;}
$int = array(111, 222, 333, 444);
if (in_array(333, $int)) {
.... do something....;}
AWOL:
It depends, to a certain extent, on the representation of the data.
Sorry but to my reading this is an obscurely phrased question - and not very clear.
Nonetheless I sought clarification and I responded with my actual code.
AWOL:
So now we've gone from strings to numbers?
This is what I regard as ridicule since it offers no help and is in no way constructive.
UKHeliBob:
The data in the array.
Determining whether a string is in an array is different from finding whether a number is in an array, hence AWOL's comment.
This post by UKHeliBob by comparison is a clear and helpful post.
It tells me I have to unthink my PHP thinking.
AWOL:
Where's the ridicule?
Seriously, point me to it.
I'm trying to get answers that will help me and others help you.
Surely you can see that data representation has a crucial bearing on your solution?
I am not sure why u were still looking for answers when I gave the actual code I wanted to replace...
FWIW the use of the term "data representation" does not impart clear meaning. Data type would have more specific meaning to me. And no, your assumption is not correct - I did not realise there was a crucial difference.
I have re-read them several times, and whilst they may be helpful to someone with your level of expertise, I am not at your level.