I want to generate a random string text of length 100 with the code below, then to verify that I print the length of the variable text but sometimes that is less than 100. How can I fix that?
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
int main() {
int i, LEN = 100;
srandom(time(NULL));
unsigned char text[LEN];
memset(text, 1, LEN);
for (i = 0; i < LEN; i++) {
text[i] = (unsigned char) rand() & 0xfff;
}
printf("plain-text:");
printf("strlen(text)=%zd\n", strlen(text));
}