CJCoding With Joseph
15free / daySign inCreate account

Mastering C Textbook

20 Questions On C String Functions

Working With C Strings

These practice questions are designed to help you learn exactly how and when to use each string function.

For each question, separate it using a clear comment in this format:

/*
 * QUESTION 1
 */

Start with Question 1 at the bottom of your file. Then write Question 2 above it, and continue stacking each new question on top.

This way, your file will have Question 20 at the top and Question 1 at the bottom, so the newest question always runs first when you test your code.


Practice Questions For strcpy()

  1. Copy your name into a string

    • Create a character array that is large enough to hold your full name.

      • Remember: you need one extra space in the array for the null terminator ('\0') at the end of the string!

    • Use strcpy() to copy your full name into the array.

    • Print the name using printf() with the %s format specifier.

  2. Replace part of a sentence

    • Declare a character array and set its value to "Today is a good day."

    • Use strcpy() to replace the text with a new string: "Today is a great day."

      • Important: Make sure the array is large enough to fit the new sentence, which is longer than the original.

    • Print the updated sentence using printf() with %

  3. Assign a new message using strcpy()

    • Create a character array that can store at least 50 characters.

      • Reminder: Always include one extra space for the null terminator ('\0') at the end of the string!

    • Use strcpy() to copy the message "Welcome to Coding with Joseph!" into the array.

    • Print the message using printf() with the %s format specifier.

Members only

Keep reading this lesson

You've reached the end of the free preview. Unlock the rest of this lesson plus 11 more lessons in Mastering C Textbook.

  • Unlimited coding questions
  • Unlimited access to all classroom material
  • Weekly live call for questions and guidance
  • 3,000 AI tutor tokens / month
  • Personal SQL database (3 MB)
  • Progress tracking

Cancel any time.