没注释的源代码
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
using namespace std;
void copystr(char *p1,char *p2,int m);
int main()
{
char str1[100],str2[100];
int m;
cout<<"please input string:"<<endl;
gets(str1);
cout<<"which character that begin to copy?: ";
cin>>m;
if(strlen(str1)<m)
cout<<"input error!";
else
{
copystr(str1,str2,m);
cout<<"now result:"<<str2;
}
return 0;
}
void copystr(char *p1,char *p2,int m)
{
int n=0;
while(n<m-1)
{
n++;
p1++;
}
while(*p1!='\0')
{
*p2=*p1;
p1++;
p2++;
}
*p2='\0';
}