Tracing shared data through a copied structure

A C program stores a record count and a pointer to an external integer in a structure. After the following code executes, which statements are true immediately before main returns? Select all that apply.


C
struct Buffer {
    int length;
    int *used;
};

void revise(struct Buffer b, int *replacement)
{
    b.length += 2;
    *b.used += 4;
    b.used = replacement;
    *b.used += 1;
}

int main(void)
{
    int first = 20;
    int second = 30;
    struct Buffer original = {6, &first};
    revise(original, &second);
    return 0;
}
Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Passing Structures to Functions Questions: