Hi, It's a beginners question: Why is this breaking/giving an error?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *strtrim_right(char *p)
{
char *end;
int len;
len = strlen( p);
while (*p && len)
{
end = p + len-1;
if(isalpha(*end))
*end =0;
else
break;
}
return(p);
}
int main ()
{
char *x="PM123BFD";
strtrim_right(x);
printf("%s", x);
return 0;
}