这似乎是一个愚蠢的问题,但我找不到答案。
\n无论如何,如果将字符串中的任意字符设置为 null,然后释放该字符串,是否会导致内存泄漏?
\n我想我对 free 函数如何工作的了解是有限的。
\n/*\n char *\n strchr(const char *s, int c);\n\n char *\n strrchr(const char *s, int c);\n\n The strchr() function locates the first occurrence of c (converted to a\n char) in the string pointed to by s. The terminating null character is\n considered part of the string; therefore if c is \xe2\x80\x98\\0\xe2\x80\x99, the functions\n locate the terminating \xe2\x80\x98\\0\xe2\x80\x99.\n\n The strrchr() function is identical to strchr() except it locates the\n last occurrence of c.\n*/\n\nchar* …Run Code Online (Sandbox Code Playgroud)