在给定文本中查找子字符串.. C程序

AGe*_*eek 3 c

char *substring(char *text, int position, int length)
{
   int i, j=0;
   char *temp ;

   for(i=position-1; i<position+length-1; i++)
   {
     temp[j++] = text[i];
   }
   temp[j] = '\0';

   return temp;
}
Run Code Online (Sandbox Code Playgroud)

嗨以下代码中的错误是什么..我试图在Fedora机器上运行它..它给我一个运行时错误"分段错误".什么是这个错误..为什么它会给出这个错误..

谢谢..

Dan*_*ach 6

temp 没有初始化.