忘了写return 0;了
写论文了,这么简单的题目都不会做怎么写论文?
哦.我忘了得用函数调用了.改下
#include <stdio.h>
#include <string.h>
#define MAX_LEN 10
int main(void)
{
int m;
char str[MAX_LEN];
char buf_out[MAX_LEN];
menset(str,0,MAX_LEN);
menset(buf_out,0,MAX_LEN);
puts("pleas input the string:");
strncpy(str,gets(),MAX_LEN);
puts("pleas input the m:");
scanf("%d",&m);
while(m>MAX_LEN || m<1)
{
printf("the m must between 0 and %d",MAX_LEN-1);
scanf("%d",&m);
}
mycopy(buf_out,str,m);
return 0;
}
char *mycopy(char *dst, char *src, int n)
{
strcpy(dst,&src[n]);
return dst;
}
我突然想起个事,你们老师是不是要求你们不能用string.h中的函数?或者你们还没学这些库函数呢?