2
0

strcpy.c 325 B

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