C pointer and string
Is it possible to read in string from stdin and store in a pointer if I didn't know the dimension of the string?
C pointer and string
Is it possible to read in string from stdin and store in a pointer if I didn't know the dimension of the string?
Not only is the ultimate length of input not known at run-time, but the length of chunks of input coming in are not known either. However the answer is yes, it is possible to do what you have asked, but will require dynamic memory allocation using either malloc or calloc AND realloc. Using these functions in conjunction will allow you to capture the input from stdin
without knowing beforehand how much there will be.