Hi for some reason my array prints out a bunch of 0's and other unwanted integer garbage. I can't see why because i originally assigned number to an array 1-31 using something like array[]={1, 2,3...31}

something like that, and then i use a for or while loop in the code to print the array using cout, however i get a bunch of 0's i'm confused.
please look over a bit of my code.

int temp=dayselector; //temp will equal 4 or anything
while (temp >= 0)
{
cout << "  ";
temp--;
}

 int i=0; 
while (counter > 0) //counter would be 31
{
    if (dayselector < 8)
    {
    cout << array[counter] << "  ";
    dayselector++;
    counter--;
    i++;
    }
    else
    {
    cout << "\n";
    dayselector=0;
    }
}
}

Can you show us where you define the array itself? It might be easier if you post most/all of the source code.

And what is the variable " counter " set to ?

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.