strcpy.c 356 B

12345678910111213141516171819
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "test_helpers.h"
  4. int main(void) {
  5. char dst[20];
  6. strcpy(dst, "strcpy works!");
  7. puts(dst);
  8. strncpy(dst, "strncpy works!", 20);
  9. puts(dst);
  10. // Make sure no NUL is placed
  11. memset(dst, 'a', 20);
  12. dst[19] = 0;
  13. strncpy(dst, "strncpy should work here too", 10);
  14. puts(dst);
  15. }