小编Lar*_*ara的帖子

const char* 应该在 C 中释放吗?

请考虑以下代码。我想问一下这是否正确,是否缺少什么。还有其他方法可以制作吗。

#include <stdio.h>
#include <string.h>
const char *getOrder (const char *day)
{
    if (strncmp(day, "Monday", 7) == 0) {
        return "first";
    } else if (strncmp(day, "Tuesday", 7) == 0) {
        return "second";
    } else if (strncmp(day, "Wednesday", 9) == 0) {
        return "third";
    } else if (strncmp(day, "Thursday", 8) == 0) {
        return "forth";
    } else if (strncmp(day, "Friday", 6) == 0) {
        return "fifth";
    } else if (strncmp(day, "Saturday", 8) == 0) {
        return "sixth";
    } else if (strncmp(day, …
Run Code Online (Sandbox Code Playgroud)

c free constants function char

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

标签 统计

c ×1

char ×1

constants ×1

free ×1

function ×1