the code i have is

{
             cout << "Please Enter the title as a lowercase value";
 getline (cin,title);
   
string mystr = "example";

for (size_t = int i; i < mystr.size(i);i++); //we need i's type to match the type of mystr.size()

{ //leaving it as an int will elicit a warning from the compiler in some cases

mystr[i] = tolower(allTitles[0][i]); //your books are already in an array so just

mystr // [n] is that what your are hinting at
 {

the extra int by kepping i int is ignored by the complier i need to define this function i am really confused about it sorry

allTiles[0] is "Book 1"
allTitles[0][0] is 'B'  //which is a char
allTitles[0][1] is 'o'
allTitles[0][5] is '1'

Just like:

mystr = "example"
mystr[0] is 'e'
mystr[5] is 'l'

Step through them in a loop just like you would with an array.

that makes sense it is just the fucntion definintion

so for the book1 [0] = book 1

then each letter has to be converted to lowercase that is fine


then [1] = book 2 etc

so for the above i would write allTitles[0] above the for statement then step through the letters will post and you can guide me


like so

string Alltitles [0] = "Book 1"
allTitles [0][1] = "B"
allTitles [0][2] = "O"
allTitles [0][3] = "O"
allTitles [0][4] = "K"
allTitles [0] [5] = " "
allTitles [0] [6] = "1"


for (size_t int i; i < mystr.size(i);i++); //we need i's type to match the type of mystr.size()

{ //leaving it as an int will elicit a warning from the compiler in some cases

mystr[i] = tolower(allTitles[0][i]); //your books are already in an array so just

or should it go below the for loop

On line 7, just scratch out the "size_t=" part and leave the int i and set it equal to zero.

For the allTitles, I would just make the array values in lowercase to begin with. In the above case I would do the transformation on title, writing it back to title: title[i] = toupper(title[i]); As far as the stuff with n goes, I was thinking if you wanted to change the arrays to lowercase programmatically

for loop over i for each of the books
{
    for loop over n for each of the characters
    {
         allTiles[i][n] = tolower(allTitles[i][n]);
     }
}

okay have scratched out the size_t= have set to int i = 0

ow have to get the rest of the for loop right the my.size () does that need to change to int or remove that and the lower all titles i [n] should it look like the section above the for loop

Just leave the size() method where it is, it will be a "close enough" match. If you haven't learned a lot of this stuff yet it might be best to focus your efforts on the other portions before this one.

Skip the lower all titles part and just make the string in your array "book 1" instead of "Book 1". Just run the loop over your title string that the user has just inputted.

sorry i haven't been online in the array declaration before main it is defined in lowercase so i did that. to run the loop over the title string inputted using the code i posted earlier as i haven't edited it as it is late move the method you showed me then i am still not sure on it size is as () but i get error size unknown declare size it is not detecting this i have the earlier part will have to recheck the check function now that i have lowercase data stored in the array.

by removing it i get

# include <iostream>

      # include <string>
  
      const int MAXSIZE = 300;
  
      using namespace std;
 
      bool findTitlePrice(string allTitles[MAXSIZE], double allPrices[MAXSIZE], int totalRec, string title, double price); //the names of the parameters are optional
  
      string allTitles[MAXSIZE] ={
  
      "Book 1",

      "Book 2"
  
      };
  
      double allPrices[MAXSIZE] = {

      78.5, 66.0 };

      //in the prototype
  
      int main()

      {
 
      string title;

      double price;
  
      int totalRec =2;
 
      findTitlePrice(allTitles,allPrices,totalRec,title,price);
 
      }
 
      bool findTitlePrice(string allTitles[2], double allPrices[2], int totalRec,

      string title, double price)
 
      {
 getline (cin,title);
      for (int i=0;i<2;i++) {
 
     

      if (title==allTitles[i])
 
      {
  
      cout << " Book Found";

      cout <<" Here is The Title of the Book" << allTitles [i];

      cout << " Here is The Price Of the Matched Book" <<allPrices [i];

      return true;

      }
     
      }

cout << " Book Not Avaliable";

      return false;

      cin.get ();

      }

This is one version of it i need to get it done in the next couple of hours


here is the one we have been using

# include <iostream>
    
      # include <string>
      # include <cctype>
      const int MAXSIZE = 300;
  
      using namespace std;
 
      bool findTitlePrice(string allTitles[MAXSIZE], double allPrices[MAXSIZE], int totalRec, string title, double price); //the names of the parameters are optional
  
      string allTitles[MAXSIZE] ={
  
      "book 1",

      "book 2"
  
      };
  
      double allPrices[MAXSIZE] = {

      78.5, 66.0 };

      //in the prototype
  
      int main()

      {
 
      string title;

      double price;
  
      int totalRec =2;
 
      findTitlePrice(allTitles,allPrices,totalRec,title,price);
 
      }
 
      bool findTitlePrice(string allTitles[2], double allPrices[2], int totalRec,

      string title, double price)
 
      {
             cout << "Please Enter the title as a lowercase value";
 getline (cin,title);
   




for (int i = 0; i<2,i++;)
{ //leaving it as an int will elicit a warning from the compiler in some cases

allTitles[i] = tolower(allTitles[0][i]); //your books are already in an array so just

 {
 
     

      if (title==allTitles[i])
 
      {
  
      cout << " Book Found";

      cout <<" Here is The Title of the Book" << allTitles [i];

      cout << " Here is The Price Of the Matched Book" <<allPrices [i];

      return true;

      }
     
      }

cout << " Book Not Avaliable";

      return false;

      cin.get ();

      }}

Im sure i am missing something now all the values are stored lowercase in the array


Thanks for any help you have and may provide in the future :)

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.