Before beginning to fill it, the s should be assigned.
1) If you do not know the length of the input string in advance, you can use realloc.
char* s = calloc(1,sizeof(char));
char t;
int len;
while(scanf("%c", &t)==1)
{
if(t== '\n')
break;
len = strlen(s);
s= realloc(s,len+1);
*(s+len) = t;
*(s+len+1) = '\0';
}
2) Now, if you know in advance the maximum length of your input string, you may read it directly into a char array with scanf as
follows:
char s[256] // Let's assume that the max length of your input string is 256
scanf("%[^\r\n]",s) // this will read your input characters till you heat enter even if your string