Question: How do i create a four byte unicode (an emoji in this case) from a integer created by the rand() function? In C plz. //
How do i create a four byte unicode (an emoji in this case) from a integer created by the rand() function? In C plz.
// Return a random emoji stored in new heap memory you have allocated. char *emoji_random_alloc() { // return ""; char* out = malloc(100); // creating a random integer between 126976 (=17000) // and 129535 (=129535) int tmp rand() % 2559 + 126976; printf("tmp %d in decimal %x in hex ", tmp, tmp); strcpy(out, tmp); return out; } // Return a random emoji stored in new heap memory you have allocated. char *emoji_random_alloc() { // return ""; char* out = malloc(100); // creating a random integer between 126976 (=17000) // and 129535 (=129535) int tmp rand() % 2559 + 126976; printf("tmp %d in decimal %x in hex ", tmp, tmp); strcpy(out, tmp); return out; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
