代码:
#include <stdio.h> #include <string.h> #define N 1024 char* fun(char* str, int m) { int totalLength = strlen(str); static char ret[N]; memset(ret, 0, N); memcpy(ret, str+m, totalLength-m); memcpy(ret+(totalLength-m), str, m); return ret; } int main(int argc, char* argv[]) { char inputStr[N]; memset(inputStr, 0, N); int moveCount = 0; puts("please input string and move count:"); scanf("%s %d", inputStr, &moveCount); puts(fun(inputStr, moveCount)); return 0; }