------------------------------------------------------------------------------------------
For example: string: AABCD one character to the left: ABCDA
L Two characters: Bcdaa
------------------------------------------------------------------------------------------
C Language code:
# include <stdio.h># include <stdlib.h># include <string.h># define max 20void contra_solem (Char *str, int move) { char *pstart = NULL; char *pend = NULL; char *src = NULL; int i = 0; pstart = str; pend = (Str + strlen (str)); src = str; for (i = 0; i < move; i++) { *pend++ = *pstart++; } while (pstart <= pend) { *src = *pstart; &Nbsp; pstart++; src++; }}int main () { char str[max] = "ABCDEFGH"; int move = 0; printf ("source string:%s\n", str); printf ("Enter the number of characters you want left-handed:"), scanf ("%d", &move); while (Move > strlen (str)) {printf ("@@@ 输入 too big, please re-enter!") @@@\n "); scanf ("%d ", &move); } contra_solem (Str,move); printf ("The string after the left%d character is:%s\n", move,str); system ("Pause"); return 0;}
------------------------------------------------------------------------------------------
Work Tip: There is no bool type in C, with an if (bool) or if (!bool) when comparing the bool type with the 0 value;
------------------------------------------------------------------------------------------
This article is from the "Nobody" blog, please be sure to keep this source http://814193594.blog.51cto.com/10729329/1708923
The C language implements the left-handed string