Code:
int len = 1;
str = malloc(sizeof(char*) * len);
printf("\nEnter The String : ");
while(scanf(" %[^\n]s", str) == 1)
Given that you've made 3 mistakes in as many lines, I'll suggest an alternative
1. You use the wrong type in the sizeof - you want char, not char*
2. You only allocate a single char - which is not enough to contain a useful string and it's trailing \0
3. Your scanf blocks on newlines, but there is no other code to remove a newline from the input stream.
Start with this
Code:
char buff[BUFSIZ];
while ( fgets(buff,BUFSIZ,stdin) != NULL ) {
// do stuff
}