slazer2au@lemmy.world to Programmer Humor@programming.devEnglish · 1 day agoEven my own code sometimes.lemmy.worldimagemessage-square93fedilinkarrow-up11.37Karrow-down12
arrow-up11.37Karrow-down1imageEven my own code sometimes.lemmy.worldslazer2au@lemmy.world to Programmer Humor@programming.devEnglish · 1 day agomessage-square93fedilink
minus-squareDon't forget to stay hydrated.🍉🍉🍉🍉🍉@sh.itjust.workslinkfedilinkEnglisharrow-up2·14 hours agoI tested it, it works as it is. #include <stdio.h> #include <stdbool.h> void main(){ bool true_or_false = true; if(true_or_false){ goto if_true; } printf("This code runs only if false.\n"); goto end_false_if; if_true: printf("This code runs only if true.\n"); end_false_if: printf("This code always runs.\n"); } If true, it jumps to if_true, then runs other code. If false, the if gets skipped, if false code gets run, then it skips over if true code.
minus-squarelukstru@piefed.sociallinkfedilinkEnglisharrow-up3·14 hours agoI totally did the thing where I commented without reading properly before. Sorry!
I tested it, it works as it is.
#include <stdio.h> #include <stdbool.h> void main(){ bool true_or_false = true; if(true_or_false){ goto if_true; } printf("This code runs only if false.\n"); goto end_false_if; if_true: printf("This code runs only if true.\n"); end_false_if: printf("This code always runs.\n"); }If true, it jumps to if_true, then runs other code. If false, the if gets skipped, if false code gets run, then it skips over if true code.
I totally did the thing where I commented without reading properly before. Sorry!