hey guys i have looked around for a solution and tried everything i can think of im new to pointers and dynamic strings and i could really do with some help with problem. im currently learning c and i need to get the user to input a dynamic size for the string length . i need to make it so the users input can not be bigger then 100 . here's where i am at currently . i have the code booting but if i try set the size to let's say 5 i can still input way more chars into the string. cheers really appreciate any help .
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main () {
    int  maxSize = 100; 
    char *name = (char*) malloc (maxSize * sizeof (char));
    int n; 
    char text1[]= ("input string size\n");
    printf ("your string lenght is %d\n", strlen(name));
    //getting size 
    n=intPrintScanner(text1);
    printf ("your size is %d\n",n);
    name = realloc (name,  sizeof (char) * n);
    //printing results 
    printf ("your string lenght is %d\n",strlen (name));
    scanf("%s", name);
    printf("your string is %s",name);
    free(name);
    fflush(stdin);
    printf("press any key to close");
    getchar();
    return (0);
}
 
     
     
    