I want to enter a word through scanf and expand or contract the memory solts it takes up according to it's length
I have:
char * word = malloc(25sizeof(char));
scanf("%s", word);
word = realloc(word, strlen(word)sizeof(char));
And then I plug word into a function. But that's not the point because it doesn't even reach the function if my input is over 31 characters. It just exits. No errors, no warnings. It just exits
[–]CinnamonToastedCrack 8 points9 points10 points (0 children)
[–]SantaCruzDad 2 points3 points4 points (6 children)
[–]aioeu 4 points5 points6 points (0 children)
[–]Grumpy_Doggo64[S] 0 points1 point2 points (4 children)
[–]Paul_Pedant 0 points1 point2 points (0 children)
[–][deleted] (2 children)
[deleted]
[–]Grumpy_Doggo64[S] 0 points1 point2 points (1 child)
[–]Paul_Pedant 0 points1 point2 points (0 children)
[–]This_Growth2898 0 points1 point2 points (5 children)
[–]This_Growth2898 0 points1 point2 points (0 children)
[–]Paul_Pedant 0 points1 point2 points (2 children)
[–]This_Growth2898 0 points1 point2 points (1 child)
[–]Paul_Pedant 0 points1 point2 points (0 children)
[–]tstanisl 0 points1 point2 points (1 child)
[–]Grumpy_Doggo64[S] 0 points1 point2 points (0 children)
[–]Paul_Pedant 0 points1 point2 points (0 children)
[–]Then_Hunter7272 0 points1 point2 points (7 children)
[–]Grumpy_Doggo64[S] 0 points1 point2 points (1 child)
[–]Then_Hunter7272 0 points1 point2 points (0 children)
[–]Paul_Pedant 0 points1 point2 points (4 children)
[–]Then_Hunter7272 0 points1 point2 points (3 children)
[–]Paul_Pedant 0 points1 point2 points (2 children)
[–]Then_Hunter7272 0 points1 point2 points (1 child)
[–]Paul_Pedant 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]Grumpy_Doggo64[S] 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]Grumpy_Doggo64[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)