I'm trying to fill a string with characters from the string 'reset\0' but randomized. For some reason it only gives me one character bacK:
#define STR_LEN 6
char *inputString()
{
char *string[STR_LEN + 1] = {0};
const char *digits = "reset\0";
int i;
for (i = 0; i < STR_LEN; i++)
{
string[i] = digits[ rand() % 5 + 0 ];
}
printf("STRING: %s\n", string);
}
prints only one character like 't' or 'e' to the console. What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire