第1个回答 2012-06-12
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc,char *argv[])
{
char *pstr;
char buf[255];
int begin,end;
int i;
if(argc !=3)
{
printf("error of inputs\n");
exit(1);
}
pstr = (char *)malloc(sizeof(char)*30);
sscanf(argv[1],"%d",&begin);
sscanf(argv[2],"%d",&end);
printf("begin = %d,end = %d\n",begin,end);
printf("inputs the string:\n");
fflush(stdout);
gets(buf);
printf("the input is \n");
printf(buf);
printf("\n");
for(i=begin;i<=end;i++)
{
*(pstr+i-begin)=*(buf+i-1);
}
*(pstr+i-begin)='\0';
printf("the output is :\n%s\n",pstr);
}