how to return a char array from a function in C

后端 未结 3 1451
时光说笑
时光说笑 2021-02-04 05:12

I want to return a character array from a function. Then I want to print it in main. how can I get the character array back in main function?



        
3条回答
  •  星月不相逢
    2021-02-04 05:54

    Daniel is right: http://ideone.com/kgbo1C#view_edit_box

    Change

    test=substring(i,j,*s);
    

    to

    test=substring(i,j,s);  
    

    Also, you need to forward declare substring:

    char *substring(int i,int j,char *ch);
    
    int main // ...
    

提交回复
热议问题