I am trying to create a dynamic character "string pointer"/array and my code will not print values is the characters typed in exceed 249 characters. I am just wondering if there is a maximum return length for a character array/"string pointer".
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *input() {
char *inpt;
char check;
int i;
int count;
i = 0;
count = 1;
check = '\0';
inpt = (char*)malloc(1);
while (check != '\n') {
check = getchar();
if (check == '\n') {
break;
} else {
inpt[i] = check;
i++;
count++;
inpt = realloc(inpt, count);
}
}
inpt[i] = '\0';
char *retrn;
retrn = inpt;
free(inpt);
printf("%d \n", i);
return retrn;
}
int main(int argc, char **argv) {
char *name;
printf("Please print name: \n");
name = input();
printf("%s is the name \n", name);
return 0;
}