Practice ยท 4 of 4
A Tiny Static Library Model
Model what ar does: bundle object files. Implement:
``c
/* archive ops: 0 = add object, 1 = remove object, 2 = link whole archive.
objects are named 'a'..'z' characters; adding an existing name replaces it. */
int archive_run(const char *ops);
`
archive_run processes ops left to right and returns the number of distinct
objects the archive would contain when a link (2`) is hit โ or -1 if a link op
occurs before any object was added. Duplicates via re-add do not increase the
count. Ops are separated by nothing ('a' then 'b' then '2').
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Duration & Linkage Gym