Make a search of char data

Hi, I'm using Microsoft Visua Studio for writing a program that stores drugstore products, it has to let the search of products by ID, name, brand, etc. The search for ID was no problem because was for numbers, but now I have to search words and I'm having a lot of doubts.

For the ID search I used a pointer that compares the ID the user wants with all the IDs that have been saved and show the matches. With the name search I don't know if I have to use strings and compare them or use only char data... I'm using a char pointer to find matches in the array structure, but when it shows the results, the program prints the same menu indefinitely.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//This is the code for the ID search that is actually working:

  void Por_ID (){   int ide;   
     cout<<"Ingrese los dos ultimos digitos del ID que desea buscar: ";         cin>>ide; cout<<"\n";
    for(l=0;l<i;l++) { 
      int *puntID; puntID = &a[l][11].ID;
	if (ide == *puntID) { 
	cout<<"ID: FS000"<<a[*puntID][11].ID<<"\n";
	cout<<"Nombre: "<<a[*puntID][0].Nombre_de_producto<<"\n";
	cout<<"Gramaje: "<<a[*puntID][1].Gramaje<<"grs.\n";
	cout<<"Marca: "<<a[*puntID][2].Marca<<"\n";
	cout<<"Presentacion: "<<a[*puntID][3].Presentacion<<"\n";
	cout<<"Fecha de Caducidad (dd/mmm/aaaa): "<<a[*puntID [4].Caducidad<<"\n";}}}


//This is the code for the name search that isn't working well: 

void Por_Nombre (){ char ide1;  int opc1;
        cout<<"Ingrese el nombre del producto que desea buscar: "; 
        cin>>ide1; cout<<"\n";
	char *puntNomb = a[0][0].Nombre_de_producto;
	    if (ide1 == *puntNomb) {cout<<*puntNomb;}}


Thank you for your time! :)
Last edited on
Topic archived. No new replies allowed.