From b8deb77c1d86870810a2b07cafb9cae068fddd84 Mon Sep 17 00:00:00 2001
From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com>
Date: Tue, 27 Feb 2024 20:49:28 +0000
Subject: Tue, Feb 27, 2024, 12:49 PM -08:00

---
 wk4/lect/copy.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

(limited to 'wk4/lect/copy.c')

diff --git a/wk4/lect/copy.c b/wk4/lect/copy.c
index 9a61c04..470340a 100644
--- a/wk4/lect/copy.c
+++ b/wk4/lect/copy.c
@@ -6,12 +6,20 @@
 
 int main(void)
 {
-    string s = get_string("s: ");
+    char *s = get_string("s: ");
 
-    string t = s;
+    char *t = malloc(strlen(s) + 1);
 
-    t[0] = toupper(t[0]);
+    for (int i = 0, n = strlen(s); i <= n; i++)
+    {
+        t[i] = s[i];
+    }
 
-    printf("%s\n", s);
-    printf("%s\n", t);
+    if(strlen(t) > 0)
+    {
+        t[0] = toupper(t[0]);
+    }
+
+    printf("%p\n", s);
+    printf("%p\n", t);
 }
-- 
cgit v1.2.3