This is one simple way to copy a string manually (not using strcpy()).
Code:
Above main:
#include <stdio.h>
void strcopyManually(char *, char *);
In main():
char str[]= {"Hello"};
char t[] = {"Goodbye"};
strcopyManually(str, t);
printf("str: %s, t: %s \n",str,t);
return 0;
}
void strcopyManually(char *s, char *t) { //using indices only, instead of pointers
int i, j;
i=j=0;
while((s[i++]=t[j++]) != 0)
; //yes, this is a one line while loop
s[i]=0; //add the end of string char to the array. NOW it's a string again.
}
if string is an array, there is no need to return anything from creating a copy. Of course, it looks almost the same way if you use pointers.
By "rotate right" -- is that a shift right or something else?