From b434383ae80950a4b17709f2bf7ac726a9cb563b Mon Sep 17 00:00:00 2001 From: zleyyij <75810274+zleyyij@users.noreply.github.com> Date: Sun, 3 Nov 2024 14:30:04 -0700 Subject: [PATCH] vault backup: 2024-11-03 14:30:04 --- .../ECE1400/Chapter 13 Exercises.md | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/education/software development/ECE1400/Chapter 13 Exercises.md b/education/software development/ECE1400/Chapter 13 Exercises.md index 7590c81..a953771 100644 --- a/education/software development/ECE1400/Chapter 13 Exercises.md +++ b/education/software development/ECE1400/Chapter 13 Exercises.md @@ -38,4 +38,23 @@ scanf("%d%s%d", &i, s, &j); --- -> **7.** Suppose that `str` \ No newline at end of file +> **7.** Suppose that `str` is an array of three characters. Which one of the following statements is not equivalent to the other three? +```c +// A +*str = 0; +// B +str[0] = '\0'; +// C +strcpy(str, ""); +// D +strcat(str, ""); +``` +(d) is different because it effectively does nothing (concatenates `"abc"` with an empty string). The rest of them make `str` effectively empty by setting the first character to a null byte. + +--- + +> **9.** What will be the value of the string `s1` after the following statements have been executed? +```c +strcpy(str, "tire-bouchon"); +strcpy(&str[4], "d-or-wi") +``` \ No newline at end of file