diff options
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); } |