代码是实现 strdup 函数功能的,但是有个错误,写得太渣,求指教

#include <stdio.h> #include <stdlib.h> char* _sF(char* s, int len) { char* F = (char*)malloc(sizeof(char) * len); for(int i = 0; i < len; i++) { F[i] = s[i]; } F[len] = '\0'; return F; } int main() { char *s="hello"; char *d; d=_sF(s); printf("%s",d); free(d); return 0; }