发布时间:2019-07-29 22:03:13
代码如下:
char * longestCommonPrefix(char ** strs, int strsSize){
char *c = (char *)malloc(sizeof(char)*128);
int j = 0;
int k = 0;
while(strs[0][j]){
char s = strs[0][j];
for(int i = 1; i < strsSize; i++)
{
if(strs[i][j] != s)
{if(k == 0)
return "";
c[k] = 0;
return c;
}
}
c[k++] = s;
j++;
}
}
显示错误:
solution.c: In function 'longestCommonPrefix'
Line 20: Char 1: error: control reaches end of non-void function [-Werror=return-type]
}
^
cc1: some warnings being treated as errors
编辑器自己调,程序还要别人告诉你怎么改? 码农都是自己动手改的,改几次水平就提高了
!會員是要充值的!