Implementation of ToLower function in C

前端 未结 4 1092
不知归路
不知归路 2021-01-27 08:28

I am writing my own implementation of ToLower(char *str) in C. But i am getting segmentation fault in the function. The function which i wrote is :

void ToLower(         


        
4条回答
  •  花落未央
    2021-01-27 09:01

    It's generally considered to be good form to accept a length parameter in functions that operate on strings. This way, if you pass in a string that's not null-terminated, the function won't loop past the end of the input.

    You could step through the function call with a debugger, or add a print statement in the loop and see how many times it's iterating.

提交回复
热议问题