Implement left-handed string in C Language
For example, the character string AABCD is a left-handed character: ABCDA. The left-handed character is BCDAA. The C language code is as follows:
# Include <stdio. h> # include <stdlib. h> # include <string. h> # define MAX 20 void 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; pstart ++; src ++;} int main () {char str [MAX] = "abcdefgh"; int move = 0; Printf ("Source string: % s \ n", str); printf ("Enter the number of left-handed characters:"); scanf ("% d", & move ); while (move> strlen (str) {printf ("@ the input is too large. Please enter it again! @ \ N "); scanf (" % d ", & move);} Contra_solem (str, move); printf (" Left % d character strings: % s \ n ", move, str); system (" pause "); return 0 ;}