返回非NULL字符串会导致编译错误

时间:2016-01-15 00:41:51

标签: c

我正在尝试在C中做一些非常简单的事情,即处理并返回一个char,并使该函数的返回值成为另一个函数中的“可用”字符。

char name_the_file(char *fileName) {
    if (fileName == NULL) {
        fileName = "myFile";
    }
    globalFile = fileName;
    return fileName;
}

FILE *load_File(char *fileName) {
    fileName = name_the_file(fileName);
    FILE *filePointer;
    filePointer = open_file(fileName);
    return fopen(fileName, "r");
}

我一直在接受诊断:warning: assignment makes pointer from integer without a cast [enabled by default]并且我不明白我在做什么有什么问题。我无法重新定义fileName

1 个答案:

答案 0 :(得分:6)

您将返回== Compilation error on file web/router.ex == ** (ArgumentError) repo MyApp.Repo is not started, please ensure it is part of your supervision tree lib/ecto/query/planner.ex:91: Ecto.Query.Planner.cache_lookup/3 lib/ecto/query/planner.ex:72: Ecto.Query.Planner.query/4 lib/ecto/repo/queryable.ex:91: Ecto.Repo.Queryable.execute/5 lib/ecto/repo/queryable.ex:15: Ecto.Repo.Queryable.all/4 web/router.ex:25: (module) (stdlib) erl_eval.erl:669: :erl_eval.do_apply/6 (elixir) lib/kernel/parallel_compiler.ex:100: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/8 ,而不是char *。您的代码似乎实际上需要char才能返回name_the_file,因此请将原型更改为:

char *