小编Kal*_*n C的帖子

如何从私有 github 存储库共享项目?

我一直在做一个项目并上传到github。现在想申请实习,把项目放在简历里。问题是 repo 是私有的,所以我不能分享它。有没有足够的方法可以在我的 repo 中共享这个项目?如果不是,那么提供可共享链接的 git 站点是什么,以避免将来出现此问题?提前致谢。

git github

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

如何在C中返回指向字符串数组的指针

函数如何返回指向字符串数组的指针?

我必须不使用C的string.h库来执行此操作。这是我到目前为止的内容:

#include <stdio.h>
#include <stdlib.h>

char* myFunc(){
    char* result[2];

    // the strings are originally dynamically allocated with some
    // function parameters which i've omitted to simplifiy the question.

    result[0] = "abc";
    result[1] = "def";
    return result;   
}

int main(void){
    char* result = myFunc();
    printf("%s\n%s\n", result[0], result[1]);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我希望有两个字符串,但是编译器将返回以下内容:

error: return from incompatible pointer type [-Wincompatible-pointer-types]
     return result;
Run Code Online (Sandbox Code Playgroud)

c arrays string pointers

-1
推荐指数
1
解决办法
80
查看次数

标签 统计

arrays ×1

c ×1

git ×1

github ×1

pointers ×1

string ×1