Unit testing for a function (tolower) using pointers

In your main:

char * str2 = "";

and then you pass str2 as a parameter, but it has too little storage and that storage is further read-only memory (points to a literal). The result is your crash. Use:

char str2[32] = 0;

or any length you need, including a null terminating character.

Leave a Comment