hye..its kinda easy..but i still cant solve it..

1.Write a program that has an array of at least 10 string objects that hold student’s ids and names, you may make-up your own strings or use the following:

“1000614921, Abdulkadir Musa Jibrin”
“1000717859, Abdulwahab Ali Esmail Al-Nawah”
“1000716597, Ahmed Ebrahim Mohammed Al-Moay”
“1000820803, Arash Moeenjahromi”
“1000715628, Azaribe Antionette Doris”
“1000717577, Fahmi Abdulqader Ahmed Ali”
“1000818032, Fares Mohammed Mohammed Askn”
“1000818087, Khairalah Fadhl Qasem Al-Galal”
“1000715803, Liman Sadiq Musa”
“1000820441, Lin Joo Foong”

The program should ask the user to enter name, partial name or student id to search for in the array. Any entries in the array that match the string entered should be displayed. For example, if the user enters “Mohammed” the program should display the following names from the list.

1000716597, Ahmed Ebrahim Mohammed Al-Moay
1000818032, Fares Mohammed Mohammed Askn

this is what I have done

#include <iostream>

#include <string>





using namespace std;

void search(string data[], string ayat)
{
    int j;
    
    for(j=0; j < 10; j++){
        if(data[j] == ayat)
            cout<<"output:";
            cout<<data[j] << endl;

        }
}




int main(){
string ayat;

 string data[10] =  {"1000614921, Abdul kadir Musa Jibrin",
             "1000717859, Abdul wahab Ali Esmail Al-Nawah",
             "1000716597, Ahmed Ebrahim Mohammed Al-Moay",
             "1000820803, Arash Moeenjahromi",
             "1000715628, Azaribe Antionette Doris",
             "1000717577, Fahmi Abdul qader Ahmed Ali",
             "1000818032, Fares Mohammed Mohammed Askn",
             "1000818087, Khairalah Fadhl Qasem Al-Galal",
             "1000715803, Liman Sadiq Musa",
             "1000820441, Lin Joo Foong"};


cout<<"Enter string: "<<endl;
getline(cin,ayat);


search(data, ayat);

return 0;
}
if(data[j] == ayat)

This comparison will only work if the user enters the exact string that is in the data array. This is not what the question asks, you need to come up with a way to compare parts of(the entire student ID, or part of the student name) the data[j] string with ayat.

can u give me more hint?im blank T_T

awwww..thank you..
im already solve it!Thanks thanks..

btw, im using find function :)

why i put the input "Mohammed", the output is the list of the names???

sakina, mai i see your coding?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.