循环字符串

来源:互联网 发布:淄博网络推广 编辑:程序博客网 时间:2024/05/29 11:08
#include "stdafx.h"
#include<iostream>
using namespace std;


void LoopMove(char *pStr,int steps)
{
int n=strlen(pStr)-steps;
cout<<n<<endl;
char temp[127];
memcpy(temp,pStr+n,steps);
memcpy(temp+steps,pStr,n);
       *(temp+steps+n)='\0';
strcpy(pStr,temp);
cout<<temp<<endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
char pStr[100]="abcdefghi";
int steps=2;
LoopMove(pStr,steps);
cout<<pStr<<endl;
return 0;
}
原创粉丝点击