A route-label utility declares char b[8] = "map";, with string.h included. Each proposed operation starts again from this original declaration, whose unused array elements are initialized to zero. Select every statement describing defined behavior that leaves b containing the stated valid C character string.
strcpy(b, b + 1); leaves b containing the string "ap".
strcpy(b, "forecast"); leaves b containing the string "forecast".
strcat(b, ".txt"); leaves b containing the string "map.txt".
strncpy(b, "compass", 7); leaves b containing the string "compass".
Unlock full course notes by signing up
Tracing a report name
A logging utility executes the following code with string.h included. Each displayed character occupies one byte. Find the final value of strlen(report) in bytes and the maximum number of additional non-null text bytes that could be appended while retaining a terminating null character. Give both answers as exact integers.
A bounded copy can omit termination
A program tests three independent copies using the code below, with string.h included. For each row, source points to a valid string containing exactly the listed text, with one byte per displayed character. Enter its length as an exact integer in bytes and enter yes or no to indicate whether a contains a terminating null character after the copy.
Finding text inside a log path
A log viewer runs the following searches. Assume string.h has been included and all statements execute successfully.
For each returned pointer, enter its byte offset, meaning its zero-based distance in bytes from the beginning of path. Use exact integers. Enter absent when the function returns a null pointer. Measure every offset from path, including the search that starts at path + 9.
What tokenization leaves in storage
A log reader accepts either a comma or a semicolon between colour labels. It processes this mutable character array using strtok from string.h. Each later call passes NULL to continue scanning the same array; no other calls to strtok occur.
After all three calls, report the text beginning at third, without quotation marks; the zero-based byte offset of second from field; the number of comma or semicolon bytes still present anywhere in the original array; and the total number of null-character bytes in the entire array, including its original terminator. Enter all offsets and byte counts as exact integers. Count the whole array, including storage beyond its first null character.