Assuming you have an array of strings, you can use the strcmp
function to find the index of a specific string in the array. Here's an example:
main.m204 chars9 lines
This code will output 2
, which is the index of 'banana' in the myArray
array. If the string you're searching for is not in the array, the idx
variable will be empty (i.e. []
).
gistlibby LogSnag