Advertisement
informaticage

Random *void explicit example

May 15th, 2021
1,103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. typedef void *Item;
  6. Item random_num() {
  7.   int* p_numero = (int*)malloc(sizeof(int));
  8.   srand(time(NULL));
  9.   *p_numero = rand() % 10 + 1;
  10.   return (Item)p_numero;
  11. }
  12.  
  13. int main(void) {
  14.   printf("Num: %d", *((int *)random_num()));
  15.   return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement