#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main()
{
char *str;
int len;
printf("Enter the expression: \n");
scanf("%[^\n]", &str);
printf("%s\n", str);
len = strlen(str);
printf("%d\n", len);
}
I am trying input a string into a string pointer but it keeps giving me a segmentation error, however when i initialize it as char array it works fine.