The characters in b are uninitialised, they are therefore unlikely to contain a null character. You initialise the first character to 'b' and then print the array.
The char * stream operator is invoked which determines the length of the string by scanning through it until it finds a null character. As the array doesn't contain a null character it keeps reading past the end of the array until it happens to find a null character somewhere else. In your case it looks like your compiler has stored a after b in the stack so it prints all the elements of b, some other character (perhaps b is padded up to an even number of bytes in memory) then the contents of a, stopping at the null terminator at the end of a. None of this is guaranteed and will change between compilers, operating systems and even different runs of your program. Welcome to the world of undefined behaviour.
The simple fix is to initialise b to all zeros at the beginning of your program:
#include <algorithm>
#include <iostream>
int main()
{
char a[10] = "ababababa";
char b[5];
std::fill(std::begin(b), std::end(b), '\0');
char temp;
temp=a[1];
b[0]=temp;
std::cout<<b;
}
Alternatively avoid the problem completely with std::string:
#include <algorithm>
#include <iostream>
int main()
{
std::string a = "ababababa";
std::string b( 1, a[ 0 ] );
std::cout<<b;
}