I have created a program for 'search' in int array..but how do i search against the array such as read 5 student names into the array and display the location of the matched name. i tried and tried,but fail.
Looks like he wants to do a binary search. In order to do that you must have the input array sorted. Otherwise you'll have to do a linear search as filipe did. You can actually do a binary search with the std algorithm but that just returns bool true if found and false otherwise. Alternatively try lower_bound which returns an iterator. Again to use those kinds of searches the array must first be sorted! http://cplusplus.com/reference/algorithm/sort/ http://cplusplus.com/reference/algorithm/lower_bound/