在函數返回值的類型我需要實現C.錯誤使用C
我不明白爲什麼我有這個eror第15行的strcpy
源(線 - 「迴歸保存;」):
Error: return value type does not match function type
這是完整的源代碼:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
char str_cpy(char *d, const char *s)
{
char *saved = d;
while (*s)
{
*d++ = *s++;
}
*d = 0;
return saved; // line 15. here the eror
}
int main(int argc, char *argv[])
{
}
改變了''從char' return'類型'字符*' –
'saved'的類型是'char *',而返回類型是'char' –