Mega Code Archive

 
Categories / C / Code Snippets
 

Our own string copy function based on pointer

#include <stdio.h> void mycpy(char *to, char *from); int main(void) { char str[100]; mycpy(str, "testing"); printf(str); return 0; } void mycpy(char *to, char *from) { while(*from) *to++ = *from++; *to = '\0'; /* null terminates the string */ }