/****************************************
编程实现字符串的循环移位操作
函数头是这样的:
pStr是指向以'\0'结尾的字符串的指针
steps是要求移动的n
void LoopMove ( char * pStr, int steps )
{
// 请填充...
}
*****************************************/
#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;
const int MAX_LEN=255;
void LoopMove1( char *pStr, int steps )
{
int n = strlen(pStr) - steps;
char tmp[MAX_LEN];
strcpy ( tmp, pStr + n );
strcpy ( tmp + steps, pStr);
*( tmp + strlen ( pStr ) ) = '\0';
strcpy( pStr, tmp );
}
void test_LoopMove1()
{
char c[]="future_money_wifi_parent_";
cout<<"before: c[] is :"<<c<<endl;
编程实现字符串的循环移位操作
函数头是这样的:
pStr是指向以'\0'结尾的字符串的指针
steps是要求移动的n
void LoopMove ( char * pStr, int steps )
{
// 请填充...
}
*****************************************/
#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;
const int MAX_LEN=255;
void LoopMove1( char *pStr, int steps )
{
int n = strlen(pStr) - steps;
char tmp[MAX_LEN];
strcpy ( tmp, pStr + n );
strcpy ( tmp + steps, pStr);
*( tmp + strlen ( pStr ) ) = '\0';
strcpy( pStr, tmp );
}
void test_LoopMove1()
{
char c[]="future_money_wifi_parent_";
cout<<"before: c[] is :"<<c<<endl;