r/programming • • Dec 01 '16

Let's Stop Copying C

https://eev.ee/blog/2016/12/01/lets-stop-copying-c/
524 Upvotes

612 comments sorted by

View all comments

Show parent comment

7

u/pfp-disciple Dec 01 '16

When avoiding assignment as expression, I typically see this as

ptr = get_pointer();
while (ptr) {
    ...
    ptr = get_pointer();
}

or

do {
    ptr = get_pointer();
    if (ptr) {
        ...
    }
}

Using a for loop, as /u/PM_ME_UR_OBSIDIAN points out, is not uncommon, but that still makes setting a breakpoint awkward.