i think the errors occur in the second recursive call for the trans function but i dont know where exactly .. is it when i pass the variable or is it something i should be doing the deque ?
When passing a const char* (or a char array) to the string constructor it assumes it points to the first element in a null-terminated array.
The array that you create on line 21 is not null-terminated, i.e. it does not end with a null-character '\0' (zero byte). When this array is passed to the string constructor on line 22 it will loop though and copy the chars in memory until it finds a null-character. This is probably why you get all that garbage in your string.
If you want to construct a string from a char array that is not null-terminated you will need to explicitly pass the length as the second argument.
1 2
char h[]={x[0]};
string hh(h, 1);
In this case it seems a bit unnecessary to construct a char array. You can pass a char directly to the string constructor but then you also need to pass an argument to decide how many times the char should be repeated.
string hh(1, x[0]);
You can also initialize the string using {} (similar to how you initialize an array). This is probably the simplest solution but it only works on modern compilers with support for C++11 or later.