
Write record_with_id, which hands back a copy of src carrying the id you were given while the record the caller passed keeps every field it had.
record_with_id({1, 90, "malloc"}, 7)Expected result
copy id=7 score=90 name=[malloc]
src id=1 score=90 name=[malloc]For your own tracking. Tests grade your code.
record_with_id({2, 30, name}, 11) then name[0] = 'S', with name holding "segv"Expected result
copy id=11 score=30 name=[Segv]
src id=2 score=30 name=[Segv]
shared=yesrecord_with_id({0, 0, NULL}, 4)Expected result
copy id=4 score=0 name=null
src id=0 score=0 name=null
shared=yesrecord_with_id({9, -1, ""}, 3)Expected result
copy id=3 score=-1 name=[]
src id=9 score=-1 name=[]Expected files
struct_copy.cAllowed functions
None. Write every helper yourself.
Allowed headers

v0.40: Create exercises. Challenge the community.
Meet Studio →Write record_with_id, which hands back a copy of src carrying the id you were given while the record the caller passed keeps every field it had.
record_with_id({1, 90, "malloc"}, 7)Expected result
copy id=7 score=90 name=[malloc]
src id=1 score=90 name=[malloc]For your own tracking. Tests grade your code.
record_with_id({2, 30, name}, 11) then name[0] = 'S', with name holding "segv"Expected result
copy id=11 score=30 name=[Segv]
src id=2 score=30 name=[Segv]
shared=yesrecord_with_id({0, 0, NULL}, 4)Expected result
copy id=4 score=0 name=null
src id=0 score=0 name=null
shared=yesrecord_with_id({9, -1, ""}, 3)Expected result
copy id=3 score=-1 name=[]
src id=9 score=-1 name=[]Expected files
struct_copy.cAllowed functions
None. Write every helper yourself.
Allowed headers

Run the tests to grade your code
Build your code, then check each test here. Open a result to inspect its output.