I am declaring a pointer to a character inside struct, and then taking input from user to store a string in that char pointer, but getting an error,please help
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct arr
{
char *str;
int len;
} s1;
int main()
{
scanf("%s", s1.str);
s1.len = strlen(s1.str);
printf("%d", s1.len);
}
stris just a pointer, you need to allocate memory if you want to store a string