C examples for String:String Function
copies string source to string target. This is pointer based version:
void strcpy(char *target, char *source) { while((*target = *source) != '\0'){ target++; source++; } }
/* Count spaces */ #include <stdio.h> void strcpy(char *target, char *source) { while ((*target = *source) != '\0') { target++;/*from w w w. j a v a2 s. c o m*/ source++; } } int main(void) { char *str = "this is a test"; char s[80]; strcpy(s, str); puts(s); return 0; }