copy2.c 372 B

1234567891011121314151617181920
  1. /* copy2.c -- strcpy() demo */
  2. #include <stdio.h>
  3. #include <string.h> // declares strcpy()
  4. #define WORDS "beast"
  5. #define SIZE 40
  6. int main(void)
  7. {
  8. const char * orig = WORDS;
  9. char copy[SIZE] = "Be the best that you can be.";
  10. char * ps;
  11. puts(orig);
  12. puts(copy);
  13. ps = strcpy(copy + 7, orig);
  14. puts(copy);
  15. puts(ps);
  16. return 0;
  17. }