C语言对字符串循坏左移m次

代码:

#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;
}



长风破浪会有时,直挂云帆济沧海!
可通过下方链接找到博主
https://www.cnblogs.com/judes/p/10875138.html
原文地址:https://www.cnblogs.com/judes/p/15023299.html