I'm trying to implement a function that copies characters from the c string source and then stores it into the array destination. I know this is strcpy however I am not allowed to call in any functions and am not allowed to use any local variables. I also have to be able add on a null terminator on the end of it so that the array becomes a c string itself. numChars is the size that the array destination is being limited to. for example if source was "apples" and numChar was 2, the first 3 elements would be 'a', 'p' and '\0'. Below is my attempt, how would I go about this?
void copyWord(char * destination, const char * source, int numChars){
while(*destination != numChars){
*destination = *source;
destination++;
source++;
}
destination[numChars] = '\0';
}