informaticage

random char*

May 15th, 2021
794
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. typedef void *Item;
  6. Item random_char() {
  7.   char *p_char = (char *)malloc(sizeof(char));
  8.   srand(time(NULL));
  9.   *p_char = (rand() % ('a' - 'z' + 1)) + 'a';
  10.   return (Item)p_char;
  11. }
  12.  
  13. int main(void) {
  14.   printf("Char: %c", *((char *)random_char()));
  15.   return 0;
  16. }
RAW Paste Data