nom points to a string literal. string literals are read only. You cannot modify them. Doing so results in undefined behavior and that is what you're experiencing.
You also have other logic errors in capitalize that make it likely you will go beyond the end of whatever string is fed to it.
char * is a pointer. It is all a matter of what it points to. Constants are read-only, so trying to modify them can cause issues, as you have seen. If the area of memory that the point looks at is read-write, then this issue should not happen.