So I'm trying to program a function which allows the user to enter an unlimited amount of chars. For example this:
char string[100]
limits the input to 100 characters.
The code i have so far is:
#include<stdio.h>
char* uinput(){
    char *string, *current;
    int counter = 0;
    string = (char *) malloc(10 * sizeof(char));
    do{
        realloc(string, counter * sizeof(char));
        current = string + counter;
        *current = getchar();
        counter++;
    }while(*current != '\n');
    return string;
}
int main(){
    char *s;
    s = uinput();
    printf("\nYou entered: %s", *s);
    return 0;
}
I'm new to pointers, so I'm not sure why this doesn't work(Program crashes). What I'm trying to do is keep reading a character and keep relocating the string pointer so the amount of bytes keeps increasing until the user presses enter ('\n').
Thanks ~Raf
 
     
     
     
     
     
    