Code that copies the text from source to destination and then prints it as a buffer
void strcpy(char *destination, char *source, int bufferSize) {
int i = 0;
while (i < bufferSize && *source != 0) {
*destination = *source;
destination += 1;
source += 1;
i += 1;
}
*destination = 0;
}
char *text = "Tomek";
char buffer[1024];
strcpy(buffer, text, 1024);
It seems likely you want
strncpywhich does approximately this.From cppreference.com page on
strncpy:For fun, consider the following definition of your function, renamed slightly. Do you understand what's going on with the pointers?