我與編譯時,下面的警告「的gcc -ansi -pedantic -Wall conc.c」 我「米做錯了,請幫助GCC C編譯器警告「警告:控制到達......」
謝謝,
conc.c:在函數 '主': conc.c:8:1:警告:控制到達非void函數的端[-Wreturn型]
#include <stdio.h>
void contract(char s1[], char s2[]);
int main()
{
char s1[] = "abcd";
char s2[] = "zzzz";
contract(s1,s2);
}
void contract(char s1[], char s2[])
{
char temp = 'a';
int i = 0;
while (s1[i] != '\0')
{
temp = s1[i];
i++;
}
if (i != 2)
{
s2[0] = s1[0];
s2[1] = '-';
s2[2] = temp;
}
printf ("\n The first char string is %s \n the shorten one is %s \n",s1,s2);
}
簡單搜索您的警告文字會立即給出結果 –