mercredi 6 avril 2022

generate random letter from word in c - my coding seems to not work

My output is blank. I'm trying to get a random letter from a user entered word. Any help?

 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>

int main (void) {

srand((unsigned int)(time(NULL)));
int i = 0;

char char1[31];

printf("Enter a word with 30 or fewer characters (no spaces):\n ");
scanf("%c", &char1[51]);

for(i = 0; i < 1; i++)
{
    int num = 
    printf("Your random character is: %c", char1[rand() % (sizeof char1)]);
}

return 0;
}



Aucun commentaire:

Enregistrer un commentaire