x will always be smaller than 6. You loop for as long as your program runs :P
I don't quite understand the question. Just use a variable to keep track of the number of loops:
1 2 3 4 5 6 7
int count = 0;
while(condition)
{
++count;
//Code
}
std::cout<<count;
Or like Random said, use a for loop. Although if you declare the 'counter' inside the 'for' syntax then it won't live past the for loop's scope.