Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1. #include <stdio.h>
  2. #include "getnum.c"
  3. #include <math.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #define CLEAR_BUFFER while(getchar()!='\n')
  7.  
  8. void configIncognita(char * palabras[], char * incognita[], int pos);
  9.  
  10. int
  11. main(void)
  12. {
  13.  
  14.     srand(time(NULL)); /*the seed has been planted*/
  15.  
  16.     int pos,c,dim=8;
  17.     char * palabras[] = {"PROGRAMACION", "TECLADO", "PALCO", "CLAVOS", "JESUS","DESAYUNO","DADOS","MERIENDA"};
  18.     char * referencia,**incognita;
  19.  
  20.     printf("\n A H O R C A D O\n\n\n");
  21.             do{
  22.             printf("Press ENTER to start\n\n");
  23.             c = getchar();
  24.           }while(c!='\n');
  25.  
  26.     pos = rand()%8;
  27.  
  28.     referencia = malloc(*palabras[pos]);
  29.     strcpy(referencia, palabras[pos]);
  30.     configIncognita(palabras,incognita, pos);
  31.  
  32.     printf("%s\n",incognita);
  33.     printf("%s\n",referencia);
  34.  
  35.     return 0;
  36. }
  37.  
  38. void
  39. configIncognita(char * palabras[], char * incognita[], int pos)
  40.     {
  41.         int i,longitud;
  42.  
  43.         incognita = malloc(*palabras[pos]+1);
  44.         longitud = strlen(palabras[pos]);
  45.  
  46.         for(i=0 ; i<longitud ; i++)
  47.             {
  48.                 incognita[i] = '_';
  49.             }
  50.         incognita[i]='\0';
  51.  
  52.         return;
  53.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement