#include "stdafx.h"


#include <stdio.h>
#include <stdlib.h>
#define maxsize 100


typedef struct
{
    char data[maxsize];
    int len;
}strtype;

int main()
{
    void strassign(strtype &str,char c[]);
    int  substr(strtype &str,int i,int j);
    strtype str;
    int i,j;
    char c[20];
    scanf("%s",c);
    scanf("%d %d",&i,&j);
    strassign(str,c);
    substr(str,i,j);
    return 0;
}

//将字符数组的值赋给字符串


void strassign(strtype &str,char c[])
{
    int i;
    for(i=0;c[i]!='\0';i++)
        str.data[i]=c[i];
    str.len=i;
    printf("the length of string is %d.\n",i);
    printf("the string is %s\n",str.data);
}

//将字符串的从第i个字符开始的n个字符输出

int  substr(strtype &str,int i,int j)
{
    char c1[10];
    int k;
    str.len=0;
    if(i<=0||i>str.len||j<0||i+j-1>str.len)
    {
        printf("the number is error!please put in the right number!\n");
        return 0;
    }
    for(k=i-1;k<i+j-1;k++)
        c1[0]=str.data[k];
    
    printf("the length of string is %d.\n",j);
    printf("the string is %s\n",c1);
    return 1;
}