#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
char* str;
int i;
printf("Enter the String:\n");
gets(str);
int len=strlen(str)-1;
while(len>0&& isspace(str[len]))
len--;
str[len+1]='\0';
printf("Output string:\n%s\n",str);
return 0;
}
this code works absolutely fine when input is small like" trail space" but crashes on large inputs like" trailing space deleted". I dnt know whay this is happening so please help me. this program removes trailing spaces at the end of string.