mardi 11 septembre 2018

How can I print multiple things in a row with using only fork() and if?

after hours of searching I ended up here. Here's my problem:

Lets say I want to print exactly this: "AAAAABBB" (5 times "A" 3 times "B") but I must do it using ONLY fork(), if and exit(). (no multiple "printf", no "wait", no "sleep", no "for".. etc). How could I do it? I have tested it in online IDEs but I just cant print them in this exact way. The output is always confusing (AABBBAA, ABABABAA etc.) I can't seem to understand how to give priority to the parent or child without using anything but fork() and if.

Any tip is appreciated

Aucun commentaire:

Enregistrer un commentaire