diff options
author | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-02-27 20:49:28 +0000 |
---|---|---|
committer | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-02-27 20:49:28 +0000 |
commit | b8deb77c1d86870810a2b07cafb9cae068fddd84 (patch) | |
tree | 51d0341f741aa8f73e6a8f3af9ce133bd05983e9 /wk4 | |
parent | a5b1a43bfc2887994604b494ff2e48f028485439 (diff) |
Tue, Feb 27, 2024, 12:49 PM -08:00
Diffstat (limited to 'wk4')
-rw-r--r-- | wk4/lect/copy.c | 18 |
1 files changed, 13 insertions, 5 deletions
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); } |