實驗8-2-4 使用函數實現字符串部分複製 (20分)

實驗8-2-4 使用函數實現字符串部分複製 (20分)

#include <stdio.h>
#define MAXN 20

void strmcpy( char *t, int m, char *s );
void ReadString( char s[] ); /* 由裁判實現,略去不表 */

int main()
{
    char t[MAXN], s[MAXN];
    int m;

    scanf("%d\n", &m);
    ReadString(t);
    strmcpy( t, m, s );
    printf("%s\n", s);

    return 0;
}

/* 你的代碼將被嵌在這裏 */
void ReadString( char s[] )
{
	gets(s);
}
	void strmcpy( char *t, int m, char *s )
{
  t=t+m-1;
  while(*t!='\0')
  {
    *s=*t;
    s++;
    t++;
  }
  *s='\0';
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章