Hey, I would like to is there any way for deleting last item in output?
For example;
for(i=0;i<10;i++)
{
cout<<i<<" ";
}
I want delete last whitespace in output. How I can do that?
The part of code which is problem for me
for(j=0;j<10;j++)
{
if(b[j]==1)
{
cout<<j<<" ";
}
}
Array 'b' has ten element each controlling one statement to be true (if the 1st statement is true b[0]=1)
the values of 'j' is the numbers I need, but there must not be a whitespace after last one.
@whitenite1
This won't work, because depending on statements the last printed value of 'j' can be ,for example '6', it means again whitespace will be printed.((((
@Leon..
Sorry, I made a small error in the example. Here it is corrected !
1 2 3 4 5 6
for(j=0;j<10;j++)
{
cout << b[j];
if (j < 9) // Have j to equal 1 less than maximum value of j in for loop
cout << " "; // whitespace ONLY printed upto, but not including, last j in for loop
}