How can such an innocuous function break everything?

void strout(char s[],int st,int en){ for(int i = st+1;st<en;i++) putchar(s[i]); }; 
  • This is a very harmless feature. If the length is transmitted incorrectly, it will climb into an unknown area. And the function has no way to validate the data. - VladD

1 answer 1

You increase in cycle i , and the condition for exiting the cycle is st<en Thus, you end up increasing i and trying to print garbage.

 void strout(char s[],int st,int en){ for(int i = st+1;st<en;i++) putchar(s[i]); }; 

It is necessary so:

 void strout(char s[],int st,int en){ for(int i = st+1;i<en;i++) putchar(s[i]); }