Now I HAve Written The following Programs

# include <iostream>
# include <string>
# define MAXSIZE = 300
using namespace std;

bool findTitlePrice(string allTitles[300], double allPrices [300],int totalRec,string title,double price);
 
 string allTitles[300] = {
        "Book 1",
        "Book 2"};
    double allPrices[300] = {
        78.5, 66.
    };
int main () 
{


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


int totalRec =2; 
  for(int i=0;i<totalRec;i++); 
   
    string Title;
    string allTitles [300];
   cout << "Please Enter Title";
    cin >> Title;
if (Title == allTitles [300])
cout <<"Value Found";

if (Title != allTitles [300]) cout << " Book Not Found ";

system ("pause");
         
         
         }
# include <iostream>
# include <string>
# define MAXSIZE = 300
using namespace std;

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

   string allTitles[MAXSIZE]  ={ 
        "Book 1",
        "Book 2"
};
    double allPrices[MAXSIZE]  = {
        78.5, 66.0 };
    
    
int main ()
{ 
    int totalRec =2;
    string title;
    double price;
    findTitlePrice( string allTitles, double allPrices,totalRec,title,price);  
}{
bool findTitlePrice(string allTitles [],double allPrices [],int totalRec , string title ,double price);

     for (int i=0; i<totalRec; i++) {
     
         
         
         cin >> title;
         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;
         }
         
         else {
      cout << " Book Not Avaliable"; 
    return false; 
  }//End of For Statment

system ("pause");}
}

The Second one is closer to my goal though i haven't defined this very well


Basically

The Progrm must use the boolFindPrice Function which i will set to maxsize as it is too have 300 max elements in each array


Totalrec = 2 at this stage as it is the number of elements stored in each array

The Program must store the two arrays and the data


as shown


Then it must take the Cin input and compare it to the alltitles array which i was thinking of using


for (i=0 <MAxsize,I++)

{ Cin >> Title;

if (Title == allTitles [MaxSIZE]) or something similar to this to check all the elements in the allTitles array then if it finds a match cout the title and the corresponding price form the allPrices array such as if element 3 in all titles is a match cout the title stored and the price stored in element 3 of all prices.


The if a match is found return true else return false

I am 100% certain i have not prototyped these correctly but the top program complies with errors but is not structured right

Any Help on This would Be Greatly Appreciated


Thanks

Here's a skeleton for you to follow:

//#includes up here
bool myFunction(string arr[],double darr[]); //the names of the parameters are optional
                                               //in the prototype
int main()
{
    string strarray[300]; //initialize these if you need to
    double dblarray[300];

    bool result;
    result = myFunction(strarray,dblarray); //no types here for parameters or return


} //main ends before the function definition begins

bool myFunction(string arr[],double darr[]) //no semicolon
{


}

Something else to consider (even though you are just starting out) is using a vector. Then you won't have to keep track of the number of elements and the vector will expand in size if you need it to. See http://www.cplusplus.com/reference/stl/vector/vector/

Edited 6 Years Ago by jonsca: n/a

Thanks for the reply how would i initialize the vector and can i make it do the functions i want easier than the check that i am trying to do if so how would i write it to meet the requirements of my program also do you seen any way to make the function work as i am getting exhausted trying combination after combination to no avail what is the best way to declare the function as i thin that i am fairly close to my goal but haven't defined the variables correctly and am worried about the for loop.

your skeleton shows i have the basic structure pretty right but main focus is calling findTitleprice correctly and running the check on the cin input (Getline (cin,title) so that it will skipblanks are the rest of my functions close to the mark

Thanks again for your reply any additional help is much appreciated

Edited 6 Years Ago by JaimeSharp: Clarity

First, start a second file that looks just like the one in my last post. You will probably need to put a return true; at the end of your function definition. Compile the file and make sure everything is ok. Now you can add the pieces back in step by step and compile in between each.

Your for loop could be laid out better. Trace it through by hand on a piece of paper. You want to do something along the lines of 1) get the tile 2) have a for loop step through and see if it finds it (if so display the result) 3) if you've gone through the for loop and haven't found anything, then display that nothing was found. Find a way to tell if you've been through the entire for loop. You could probably use a boolean value as a flag.

That is a good idea im on my 4th try at this i thought the return true value in the loop is enough;


but i will start again if i get stuck i will post where i am upto thanks for your help on this though

if you could work on the for loop as i am stuck on the Title == function i think that is right but i was thinking if match found cout >> " Match found the title and element in price which is the corresponding price and then return true else return false as you have to return false if not match is found


I should use getline (cin,title) to skip the blanks right i think that is one of my issues the top post of mine complied without errors though maybe we can modify it to save a little bit of typing

I have Added a const Int MAXSIZE = 300 so i can use MAXSIZE as the size of the Arrays
I Have Initialized the arrays with the data in them

Error List

in the Bool myfunction string not declared in scope
expected primary expression before double
initializer expression list treated as compound expression


result = myFunction(strarray,dblarray); myfunction cannot be used as a function

In function `bool myFunction(std::string*, double*)':

line 38 `bool myFunction(std::string*, double*)' redeclared as different kind of symbol


The { after has error conflicts with funtion declaration Bool My function

and final 2 errors on line 6


Previous Declaration of Bool my function
previous non function declaration

yet # include <string> has been used
as has # include <iostream>


so the sting errors should not apply i haven't tried the for loop yet
Thanks Again

Edited 6 Years Ago by JaimeSharp: Spelling

i thought the return true value in the loop is enough;

It is in the full set of code but in the skeleton the compiler probably complains if there is no return value, so I was suggesting that as a placeholder.

then return true else return false as you hvae to return false if not match is found

Trace your code out for a scenario where the book you are looking for is third on the list. What happens after the first pass through the loop.

At the moment it is not complaining i added the return true but no condition to compare it with should i be adding the for loop and other arguments back into the code as i haven't added any of my own code in yet hence i think the errors

No it doesn't complain as long as the } is at the end of the code i tested this


In my head if the book was the third in the list and was a match providing there was 3 books in the array then it would find it


as it is i could check the first 2 elements only initially hence why i was using an i=0 < Maxsize , I++ type function so that if it occured in the array it would check all elements once to see if there is a match logically that is how i see it anyway


If the book is third the list an allTitles search is required in my head to check to the ith or as i=0 the 0 to maxsize number of elements

Looking at the second program as a guide the cin Value firstly has to become a getline but i would imagine that it would check the array once then return true or false

Edited 6 Years Ago by JaimeSharp: n/a

Here is a basic layout so far producing linker error on the findtitleprice function

##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);

     
  string allTitles[300] = {
        "Book 1",
        "Book 2"
    };
    double allPrices[300] = {
        78.5, 66.
    };

;
int main()
{
int totalRec =2;
string title;
double price;
findTitlePrice(allTitles,allPrices,totalRec,title,price);  //run it through the function
    
    cout<<"Enter a book:";
getline (cin,title);
 if (allTitles [300] == title)



 cin.get ();}

I sure it is easy to fix and i know i haven't defined the loop yet

In my head if the book was the third in the list and was a match providing there was 3 books in the array then it would find it


as it is i could check the first 2 elements only initially hence why i was using an i=0 < Maxsize , I++ type function so that if it occured in the array it would check all elements once to see if there is a match logically that is how i see it anyway


If the book is third the list an allTitles search is required in my head to check to the ith or as i=0 the 0 to maxsize number of elements

Looking at the second program as a guide the cin Value firstly has to become a getline but i would imagine that it would check the array once then return true or false

Yes, if it doesn't find on the first try it will return false and the function will be done at that point and it won't continue through the loop.

Here is a basic layout so far producing linker error on the findtitleprice function

Yes, since there is no definition of the function it has nothing to go on.

Edited 6 Years Ago by jonsca: n/a

So i should use the for loop i defined before then add the bool function after findTitlePrice to define the function


Here is what i have at the moment

#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);

     
  string allTitles[300] = {
        "Book 1",
        "Book 2"
    };
    double allPrices[300] = {
        78.5, 66.
    };

;
int main()
{
int totalRec =2;
string title;
double price;    

findTitlePrice(allTitles,allPrices,totalRec,title,price);  //run it through the function
 
         //Change This to MAXSIZE  

for (int i=0;i<totalRec;i++) {
              
    getline (cin,title);
 bool findTitlePrice (string allTitles[MAXSIZE],double allPrices[MAXSIZE],int totalRec,string title, double price);
         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;
         else 
      cout << " Book Not Avaliable"; 
    return false; 
}

 cin.get ();
 
}}

I think i am getting close though the for loop i still wrong im sure as is the postion of the bool function at the end of the code

Edited 6 Years Ago by JaimeSharp: n/a

Refer back to the skeleton code I gave you to place the function definition. Line 32 in the above listing is completely wrong.

Also, your if statement doesn't have a closing brace and if you write else without the braces the statement will encompass the else and the line immediately following it.

if (condition)
  I get executed

Not part of the statement

//versus having

if(condition)
{
   I get executed
   Part of the statement
}
else(condition)
   Part of the else
Executed regardless

I tried to explain this before, but do you want to get the title each time the code goes through the for loop? No, so move line 31 out of there and before the for.

Here's some pseudocode for your loop

READ INPUT FROM USER
FOR (over the books array)
{
  IF WE FOUND THE BOOK, SAY SO and RETURN TRUE

}
  IF WE MADE IT THROUGH THE FOR LOOP, WE HAVEN'T FOUND IT
     RETURN FALSE

Edited 6 Years Ago by jonsca: n/a

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;
         }
         else{ 
      cout << " Book Not Avaliable"; 
    return false; 
}

Now i have altered the loop a little and am still stuck with the following errors occuring

In function `int main()':

31 expected init-declarator before "if"
31 expected `,' or `;' before "if"
39 expected primary-expression before "else"
39 expected `;' before "else"
46 expected `}' at end of input

Well the last one is easy to solve the others are not i can add a ; to the declaration of the boolfunction which takes away a few of these errors otherwise line 32


line 39 makes no sense to me as i have added the braces but maybe i have too many or declared the else statement wrong

current code is basically the same as the previous one but using the for loop i provided

# 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);

   string allTitles[MAXSIZE]  ={ 
        "Book 1",
        "Book 2"
};
    double allPrices[MAXSIZE]  = {
        78.5, 66.0 };
    
    
int main ()
{ 
    int totalRec =2;
    string title;
    double price;
    findTitlePrice(allTitles,allPrices,totalRec,title,price);  
}{
bool findTitlePrice(string allTitles [],double allPrices [],int totalRec , string title ,double price);

     for (int i=0;i<totalRec;i++) {
     
         
    getline (cin,title)
         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;
         }
         
         else {
      cout << " Book Not Avaliable"; 
    return false; 
  }//End of For Statment

cin.get ();}
}

The compiler crashed without saving my changes :(


i will rewrite it again

# 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);

   string allTitles[MAXSIZE]  ={ 
        "Book 1",
        "Book 2"
};
    double allPrices[MAXSIZE]  = {
        78.5, 66.0 };
    
    
int main ()
{ 
    int totalRec =2;
    string title;
    double price;
    findTitlePrice(allTitles,allPrices,totalRec,title,price);



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

{
     for (int T=0;T<totalRec;T++) 
     
         
    getline (cin,title);
         if (title==allTitles[MAXSIZE])
         {
         cout << " Book Found";
         
         cout <<" Here is The Title of the Book" << allTitles [MAXSIZE];
         cout << " Here is The Price Of the Matched Book" <<allPrices [MAXSIZE];
         return true;
         }
         
         else {
      cout << " Book Not Avaliable"; 
    return false; 
  }//End of For Statment

cin.get ();}
}

Now only linker error as i haven't defined the function correctly before the for loop.


each time i change thing the errors change as well


so basically the code is as the rpevious version at the moment with the for loop i have defined the secondary booltitle price incorrectly im sure

Edited 6 Years Ago by JaimeSharp: n/a

You are only taking bits and pieces of what I have been telling you. In this latest version you have not closed main() with a } and kept your function definition, i.e. the

bool myFunction(string arr[],double darr[]) //no semicolon -- these parameters are just an example, use your real ones
{


}

outside of main. If you have a text, look up the use of the braces with loops -- it is critical that they match up, one for one, one { per each }. Also, look at some programs that have functions and note where the prototype and definition are located.

You'll need to fix your arrays as using MAXSIZE is correct in the definition of those arrays in lines 9 and 13 but when you try to access element MAXSIZE, you've overstepped the bounds of the array (since an array of size 4 will have index values of 0 through 3)on lines 33,37,38.

I know you think you've come too far to do this but it will save you an immense amount of time if you start a new project with no code other than the skeleton and fill in the pieces one by one, compiling as you go.

Edited 6 Years Ago by jonsca: n/a

You are about not closing main with the bool function i thought the initial declaration that occurs before main is right okay that is good to know about the other lines currently the records are stored in element 0 and 1 so wouldn't i set the array size to two as 0 - 2 will cover the two stored records which is fine for this version but not for a later incarnation of the code i have the skeleton and have put in a few functions but will try another version of the code as well now i should be calling the function FindTitleprice in main close main then initialize the second Boolfunction as i see it the reason i didn't close main was a linker error with findTitle Price

Edited 6 Years Ago by JaimeSharp: n/a

using the Skeleton this is what i have so far No compiler Errors

# 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;
   
       
   
      bool result;
  
      result = findTitlePrice(allTitles,allPrices,totalRec,title,price); //no types here for parameters or return
  
       
  
       
      } //main ends before the function definition begins
 
 
      bool findTitlePrice(string allTitles[3], double allPrices[3], int totalRec, string title, double price) //no semicolon
 
      {
 
       

       

     //return true; 
     }

Have got to this now

# 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); //no types here for parameters or return
  } //main ends before the function definition begins
 
 
      bool findTitlePrice(string allTitles[3], double allPrices[3], int totalRec, string title, double price) //no semicolon
 
      {
  for (int i=0;i<MAXSIZE;i++) {
              
    getline (cin,title);
    
    if (title==allTitles[MAXSIZE])
         {
         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;
         }
         else{ 
      cout << " Book Not Avaliable"; 
    return false; 
}

 cin.get ();
       

       

     //return true; 
     }}

}} there else complier throws error about BoolFindtitle price also the for loop seems like the ocnditions are misdefined but i haven't run the executable yet

I know that FindTitlePrice can be moved down out of main but doesn't make a difference in the compiler if the }} are removed same error


Thanks For all Your Effort jonsca :)

Edited 6 Years Ago by JaimeSharp: n/a

It seems to be when i enter a matching title it exits else displays the book not found message

# 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); //no types here for parameters or return
  } //main ends before the function definition begins
 
 
      bool findTitlePrice(string allTitles[2], double allPrices[2], int totalRec, string title, double price) //no semicolon
 
      {
  for (int i=0;i<2;i++) {
              
    getline (cin,title);
    
    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;
    }
         else{ 
      cout << " Book Not Avaliable"; 
    return false; 
}
cin.get ();
       }}

same errors as above can remove the last }

Ok, you've made some great improvements in the code. Take a look at this document on formatting http://www.gidnetwork.com/b-38.html, as formatting makes it a lot easier to read and follow and will aid in checking all the braces match.

Your function still needs some work. I've told you that you need to bring getline before the start of your for loop. Trace it out- for each time you go through the for loop (over the number of books in the array) you'd be prompting the user for a new book. Prompt the user for the title _once_. You need to disintegrate your if/else structure and turn it into an if that returns true but no else. I mentioned before that you need to return false only if you've gone through the entire for loop and not struck on the title.

Edited 6 Years Ago by jonsca: n/a

Whoops about getline i didn't see that will change it now


the return false is right though isn't it because we are testing the inputted title against all elements in the titles array it seems to be working except that it does not cout the corresponding price if i enter " book 1" it says that the book is found in

Book 0 which is the position it is stored in so it seems to be functioning partially

so basically close the for loop then return false as it would return true otherwise


or would it be better with 2 if statements

like if ==

return true


if ! ==

return false

easy enough to do that


Thanks again for all your help


will try this out

Edited 6 Years Ago by JaimeSharp: n/a

# 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) 
 
      {
      for (int i=0;i<2;i++) {
              
    getline (cin,title);
    
    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;
    }
         else{ 
      cout << " Book Not Avaliable"; 
    return false; 
    }
    cin.get ();
       }}

Basically i believe that the loop is not to far off just need it to pause the program when cout the result as i am looking at it too briefly.

Edited 6 Years Ago by JaimeSharp: n/a

the return false is right though isn't it because we are testing the inputted title against all elements in the titles array it seems to be working except that it does not cout the corresponding price if i enter " book 1" it says that the book is found in

Your test cases are betraying the true behavior of your program. Say there are four books book0,book1,book2,book3. If you are looking for book two, if you have the return false where you do now it's going to find book0!=book2 and you'll leave the function. If I were looking for book5 in this scenario I want to go through book0,book1,book2,book3 to make sure it's not the 2nd, 3rd,last book in the chain. It's a simple fix, just return false after the for loop ends and before your function ends.

Edited 6 Years Ago by jonsca: n/a

other wise say return false just before the cin.get that is where i have placed it but i am getting the same issue where it will not out the price in the prices array it accepted the input but strangely not book 2

Getting linker error then on the boolfunction i will grab the code i wrote which is in the earlier post and make the changes again compiler is crashing a bit.

Edited 6 Years Ago by JaimeSharp: n/a

Have redone the code using the previous post not complier errors have to test it but it is as follows

# 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 ();

      }

Is this right now hopefully it is is also is not pausing enough

may not be checking right no signs of price being outputted.

Edited 6 Years Ago by JaimeSharp: n/a

strangely not book 2

The case of the two strings must match exactly for them to be equal. To remedy this you can convert everything the user enters to lowercase using the functions in #include<cctype> (http://www.cplusplus.com/reference/clibrary/cctype/toupper/ there are many other ways to do it too) and make sure your array strings are all lowercase.

I ran it a couple of times and it seems to do the job but you'll have to test it thoroughly. An "optional" step would be to move your arrays into main() and out of the global space -- it's a good habit to avoid globals.

Edited 6 Years Ago by jonsca: n/a

which would be easier to implement i tried changing the values in title to book 1 in lowercase but am getting the same issue with the code will try the cctype if it works thanks for that suggestion and your continued help must be sick of this code by now :)


having not used cctype before do i declare loc.tolower in the getline function ?

Edited 6 Years Ago by JaimeSharp: n/a

No, you'll have to use array notation to march through the string you take in.

string mystr = "example";
for (size_t i = 0;i<mystr.size();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(mystr[i]); //your books are already in an array so just 
                                  //use allTitles[0][i]
}

Edited 6 Years Ago by jonsca: n/a

so within the for loop making i be a string value right

i ahve declared it using the code you wrote as

string

 for (size_t string i = 0 ;i < mystr.size ();I++)


{

mystr [i] = tolower (all titles [0] [i]);


now i know i haven't declared this right being the my str what it should be is title = getline ?

sorry if i am no getting this quite right what you are saying makes sense though

size_t is the type for your index. I was trying to be proper but it probably made it more confusing,apologies. When you ask for the size of a string using that size() method it returns a size_t value (which is usually just an unsigned int). Change it back to int for the time being if you are more comfortable with it that way. string doesn't come into the value of i at all.

Your string in question is any one of the ones stored in allTitles. So use i for your book index and change the index for the string characters to n or something.

I replied on your other thread too. You should probably stick to one or the other since they are similar. If you hit "Flag bad post" on the left under your name you can request that a mod close one or the other.

Edited 6 Years Ago by jonsca: n/a

I i know they are similar the other is the final product once i get this right then it goes into the next step then in to the final program which is what you see in the other thread

im not more comfortable with int just need to declare it right if this will do what am looking for then we shall work at it :) when i have this sorted i will close this one.

that change the index refers to the blank string statement where you have mystr = "example"

i get that i is the array index not sure on the rest of it sorry

This question has already been answered. Start a new discussion instead.