I have a command line argument which is alphanumeric, e.g. "ABCDE1234567" passed as argv[1]. I'm looking to rearrange the char* so the first 4 chars are sent to the end of the string, so it would end up like E1234567ABCD.
I'm getting the char* from the argv as follows:
char* input = argv[1];
validate(input);
then passing to a function to do the work,
void validate (char* input) {
// move the first 4 chars to the end
// this is where i'm stuck :-)
}
I know this should be easy, but I've been trying to use strcpy, sprintf, for loops, but just not getting anywhere.
edit:
I tried to copy the string without the first four chars into a buffer, but this didnt seem to produce any results:
int n = strlen(input);
char buffer [n - 4];
for (int i = 4; i <= n; i++) {
printf("%c\n", input[i]);
sprintf(buffer, "%c", input[i]);
}
printf("%s\n", buffer);