Q:

How to convert char array to string

char n[12];
sgx_read_rand(reinterpret_cast<unsigned char*>(&n),
                sizeof(n));
mbedtls_printf("ENCLAVE: Salt for the password: %llu\n", *(char *)n);
string salt(n);
mbedtls_printf("ENCLAVE: Salt for the password: %s\n", salt.c_str());

It gives output as:
ENCLAVE: Salt for the password: 4294967209
ENCLAVE: Salt for the password: ���Æ��Ѩ�
How to covert it into string?Is it even possible?
Function signature:
/* sgx_read_rand()
 * Parameters:
 *      rand - the buffer to receive the random number
 *      length_in_bytes - the number of bytes to read the random number
 * Return Value:
 *      SGX_SUCCESS - success
 *      SGX_ERROR_INVALID_PARAMETER - the parameter is invalid
 *      SGX_ERROR_UNEXPECTED - HW failure of RDRAND instruction
*/
sgx_status_t SGXAPI sgx_read_rand(unsigned char *rand, size_t length_in_bytes);

What I wanted:
I wanted the salt to get as a string data type. My Password is a string data type and I want to concatenate salt with it. As you can see when I try to get string from char array, I get binary data but when I use %llu for char array I get readable data. I want the same readable data in string. 
Update from Linux SGX developers document:
sgx_read_rand
The sgx_read_rand function is used to generate a random number inside
the enclave.
Syntax
sgx_status_t sgx_read_rand(
unsigned char *rand,
size_t length_in_bytes
);

rand variable:
A pointer to the buffer that receives the random number. The pointer cannot be NULL. The rand buffer can be either within or outside the enclave, but it is not allowed to be across the enclave boundary or wrapped around.
length_in_bytes [in]
The length of the buffer (in bytes)

Link to the developer reference: https://01.org/sites/default/files/documentation/intel_sgx_sdk_developer_reference_for_linux_os_pdf.pdf
Everyone who downvoted the question, Have a look here:
https://github.com/intel/linux-sgx/issues/263
so I did this based on comments:
char n[12];
sgx_read_rand(reinterpret_cast<unsigned char*>(&n),
                sizeof(n));

for(int i=0;i<12;++i)
{
    mbedtls_printf("%u\n", (unsigned int)n[i]);
}

And the output is 
15
73
8
4294967229
84
4294967176
53
4294967198
4294967268
91
4294967275
4294967224

I think this function just generates random bytes. Any opinion?

A:

First of all, yes it's possible to convert it to a string. But you have to understand the types you're using.
char n[12];

Here n is of type char*. If you want to convert a char* to a string it has to be null terminated. So after you fill the array with random numbers, you have to:
n[sizeof(n)-1] = '\0';

then 
string salt(n);

contains a the string representing your char array. But be warned, the random numbers might already contain a '\0', so the length of the resulting string might vary. ( 0 to 11 characters)
Let me explain, what happend in your code:
mbedtls_printf("ENCLAVE: Salt for the password: %llu\n", *(char *)n);

Here, because n already is a char*, you take *n, which is the same as n[0], and output it as %llu (unsigned long long int). The output 4294967209 in hex is 0xFFFFFFA9. You get this value because you converted the char n[0] = 0xA9 = -87 to unsigned long long int.
The string you're getting later "���Æ��Ѩ�" is correct, that are the random characters you've created. But it was pure luck, that there was a '\0' in your memory, which terminated the string. Also this looks like Unicode, I'm not sure what your environment is, but you might need to convert to wchar_t depending in which format your password is stored. But that's beyond the scope of your question.

