lundi 30 novembre 2015

Generate random elements from array having hindi characters

I am trying to develop a program using c++ that generates a random element from an array that has Hindi characters stored in it. I had hardcoded the array while initiating it e.g

std::string hindi_array[] = {std::to_string('ठ')};

now to generate a random element from the array, I have written a function that generates a random index of the array(which works fine). After I get the random index, I pass it on to another function that uses this index to print the character. The following lines are the snippet for that:

   int key = generate_random();
   sprintf(str, "%s", Hindi_array[key].c_str());
   lbl->setCaption(Rand_array[key].c_str());

lbl is a defined label here. The output that I'm getting is a number like 14722230. Are hindi characters somehow represented in this way at some level? Is there a way to transform it to the actual character that I want to display?

I am a complete newbie to c++ programming so please pardon me if it is too basic or stupid a question. Any help would be great...Thanks!




Aucun commentaire:

Enregistrer un commentaire