Skip to content

Instantly share code, notes, and snippets.

@wise-introvert
Created November 13, 2021 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wise-introvert/0f9cddf24ebec0c930d2ebd0050363c2 to your computer and use it in GitHub Desktop.
Save wise-introvert/0f9cddf24ebec0c930d2ebd0050363c2 to your computer and use it in GitHub Desktop.
1. Import the standard input and output library
2. Import the String helper library
3. Define a macro called SZ and set it to 31
4. declare a character array of size "SZ" (31) called "str1" and set it to "Charlotte's"
5. declare a character array of size "SZ" (31) called "str2" and set it to "Spider's web"
6. declare a character array of size "SZ" (31) called "str3" and initialize it with one item: 0
7. Concatenate the value of str1 and the address of the value at index 9 in the str2 array using the strcat method provided by the string helper library
8. Compare the value of str1 with "Charlotte's web" using the strcmp method.
9. If the result from step 8 is false, execute the contents in the if block (since the condition is prepend with the not (!) operator ): copy the string "is the" to the value of str3
10. If the result from step 8 is true, execute the contents in the else block (since the condition is prepend with the not (!) operator ): copy the string "is not the" to the value of str3
11. Print the values of str1, str2 and str3 in the following order: "{str1} {str3} {str2}!\n"
OUTPUT: "Charlotte's web is the Spider's web!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment