Ok, I am setting all elements in the array to 0...
If all elements are 0, i want it to display "No inventory"
if there is something in the element, i want to display only its contents..

Heres the code, how do I make it display No Inventory only when all are 0, not every single 0.

for (int i = 0; i < size; i++)             
   item[i] = 0;
for (int j = 0; j < size; j++)
    if (item[j] == 0)
    cout<<"No Inventory";
10 Years
Discussion Span
Last Post by Ancient Dragon

In that last loop you have to just count the number of items that are zero. Then after the end of the loop if the counter is still zero you can display the "no Inventory" message.


Is there a function in C++ where a string can be held in a Unsigned array?

I don't know how that relates to your original question, but its not called a function but a container. such as vector<string> array; . Or if you mean you want to put a c-style null-terminated string into an array, then try vector<char*> array;

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.