I'm learning C and I have encountered a problem when printing out a string which contents I generated randomly.
The code below prints out only the first 89 characters and I need to get the whole 1000.
I have tried searching for similar questions and looking up c tutorials but I could not find the explanation. Any help is appreciated.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
srand(1000);
int i;
char *niz;
niz = calloc(1001, sizeof(char));
for (i = 0; i < 1000;i++){
int randbroj = rand() % 62;
if (randbroj < 10){
niz[i] = randbroj + 48;
}
if (randbroj > 10 && randbroj < 36){
niz[i] = randbroj + 55;
}
if (randbroj > 35 && randbroj < 62){
niz[i] = randbroj + 61;
}
}
niz[1000] = '\0';
printf("%s",niz);
return 0;
}