From ead450fd8b8d0de2a36c9a1277e11594f2ab6457 Mon Sep 17 00:00:00 2001 From: tmeissner Date: Fri, 15 May 2015 11:00:27 +0200 Subject: [PATCH] refactoring of this_row() funct. by using pointer to string literals --- 21st_century_c/boxes.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/21st_century_c/boxes.c b/21st_century_c/boxes.c index 6ad27bb..6a1c61e 100644 --- a/21st_century_c/boxes.c +++ b/21st_century_c/boxes.c @@ -31,15 +31,17 @@ int main() { void this_row(direction_s d) { - char s[] = ".*.\n"; + char *c; if(d.left) { - strlcpy(s, "*..\n", sizeof(s)); + c = "*.."; } else if(d.right) { - strlcpy(s, "..*\n", sizeof(s)); + c = "..*"; + } else { + c = ".*."; } - printf("%s", s); + printf("%s\n", c); }