slicing a string

 #include<stdio.h>

void slice(char s[],int n,int m);
int main()
{
    char s[]="hello world";
    slice(s,3,7);
}
void slice(char s[],int n,int m)
{
    char newstr[100];
    int j=0;
    for(int i=n;i<=m;i++,j++)
    {
    newstr[j]=s[i];
    }
    newstr[j]='\0';
puts(newstr);
}

Comments