待测

来源:互联网 发布:win平板安装ubuntu 编辑:程序博客网 时间:2024/04/29 10:48

#include <stdio.h>

#include <malloc.h>

#include <assert.h>

#include <string.h>

#define MAX 6


//缓缓右移n个

void Loopmove1(char *pStr, int steps)

{

int strlen(pStr) steps;

char tmp[MAX];

strcpy(tmp, pStr+n);

strcpy(tmp+steps, pStr);

*(tmp strlen(pStr)) '\0';

strcpy(pStr, tmp);            //出错啦

}


void Loopmove2(char *pStr, int steps)

{

int strlen(pStr) steps;

char tmp[MAX];

memcpy(tmp, pStr+n, steps);

memcpy(pStr+steps, pStr, n);   //出错啦

memcpy(pStr, tmp, steps);

}

int main()

{

int 3;

char *f "123456789";


Loopmove1(f, n);

Loopmove2(f, n);


printf("%s\n",f);


return 0;

}