From 5c26c657d5f6d722a4bb0c40d3e3deecd2560314 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sun, 30 Jul 2023 01:03:55 +0300 Subject: [PATCH] clear string --- ~/C/clear_string.c | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 ~/C/clear_string.c diff --git a/~/C/clear_string.c b/~/C/clear_string.c new file mode 100644 index 0000000..4ab0bab --- /dev/null +++ b/~/C/clear_string.c @@ -0,0 +1,10 @@ +int main(int argc, char const *argv[]) +{ + char *buffer = malloc(256 + 1); + + buffer[0] = '\0'; + strcpy(buffer, ""); + memset(buffer, '\0', sizeof(buffer)); + + return 0; +}