title: How to print everything from an struct array in c++?
body: <p>I have a structured a data type called bookStruct and books is the name of the variable associated with the bookStruct data type. book[10] is the array that is 10 characters long and has 4 characters of data, meaning book[0] to book [3] have datas in them when the rest are empty (o values). Now I want to print the datas that are availabe already in the array and not print the ones that are empty otherwise 0. I tried the below code, with no luck.What am I doing wrong here?</p>
  
  <pre><code>for (int i=0;i&lt;MAX_BOOKS &amp;&amp; books[i]!='\0';i++)
              {
                  cout &lt;&lt; "Book Title: " &lt;&lt; books[i].bookTitle &lt;&lt; endl;
                  cout &lt;&lt; "Total Pages: " &lt;&lt; books[i].bookPageN &lt;&lt; endl;
                  cout &lt;&lt; "Book Review: " &lt;&lt; books[i].bookReview &lt;&lt; endl;
                  cout &lt;&lt; "Book Price: " &lt;&lt; books[i].bookPrice&lt;&lt; "\n\n" &lt;&lt; endl;
              }
  </code></pre>
  
  <p>here is the declaration for book struct</p>
  
  <pre><code>struct bookStruct
  {
      string bookTitle;
      int bookPageN;
      int bookReview;
      float bookPrice;
  };
  
  bookStruct books[10];
  </code></pre>