小编Nor*_*tar的帖子

在 C 中将字符串 char 设置为 null 是否会导致内存泄漏?

这似乎是一个愚蠢的问题,但我找不到答案。

\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)

c memory arrays string memory-leaks

2
推荐指数
1
解决办法
352
查看次数

标签 统计

arrays ×1

c ×1

memory ×1

memory-leaks ×1

string ×1