Fix strcpy

This commit is contained in:
jD91mZM2
2018-08-07 11:35:23 +02:00
parent f6ca7d7c2d
commit 3bb3a3e322
6 changed files with 76 additions and 27 deletions
+17
View File
@@ -0,0 +1,17 @@
#include <stdio.h>
#include <string.h>
int main() {
char dst[20];
strcpy(dst, "strcpy works!");
puts(dst);
strncpy(dst, "strncpy works!", 20);
puts(dst);
// Make sure no NUL is placed
memset(dst, 'a', 20);
dst[19] = 0;
strncpy(dst, "strncpy should work here too", 10);
puts(dst);
}