我一直在做一个项目并上传到github。现在想申请实习,把项目放在简历里。问题是 repo 是私有的,所以我不能分享它。有没有足够的方法可以在我的 repo 中共享这个项目?如果不是,那么提供可共享链接的 git 站点是什么,以避免将来出现此问题?提前致谢。
函数如何返回指向字符串数组的指针?
我必须不使用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)