memesearch
Help with Order of Precedence

Help with Order of Precedence

Download Find similar pictures
Text on the meme
Help with Order of Precedence. I am building a terminal based calculator but I have run into an issue with order of precedence/operations because it just reads the input string from right to left. for example: 10+6*6 = 96 I cannot figure out how to sort the string so it will execute correctly. #include <unistd.h> // include unistd.h library. char expression[32]; // create 32bit buffer for equation. char operation[32]; // create 32bit buffer for mathematical operators. int numbers[32]; // create 32bit buffer for numbers in expression. int op_index =0; // create index for operator buffer. int num_index =0; // create index for value buffer. int op_len; int ascii; // define int type 'ascii'. int digit; // define int type 'digit'. int integer; // define int type 'number'. int digit_counter(int n){ // define function. if (n < 0) n- n*-1; // if n < 0, mul -1 than continue. if (n < 10) return 1; // if n < 10, than return 1. if (n < 100) return 2; // if n < 100, than return 2. if (n < 1000) return 3; // if n < 1000, than return 3. if (n < 10000) return 4; // if n < 10000, than return 4. if (n < 100000) return 5; // if n < 100000, than return 5. if (n < 1000000) return 6; // if n < 1000000, than return 6. if (n < 10000000) return 7; // if n < 10000000, than return 7. if (n < 100000000) return 8; // if n < 100000000, than return 8. if (n < 1000000000) return 9; // if n < 1000000000, than return 9. return 10; } int main(void){ // define main function. read(0, expression, 32); // read input string in buffer
What it means

A screenshot of a Reddit programming post asks for help implementing order of precedence in a terminal-based calculator. The joke is that the code is full of amateur mistakes and even claims to read input from right to left, while the example and comments expose the programmer’s confusion; it is shared as a humorous coding fail or reaction to messy beginner code. EN: A screenshot of a Reddit programming post asks for help implementing order of precedence in a terminal-based calculator. The joke is that the code is full of amateur mistakes and even claims to read input from right to left, while the example and comments expose the programmer’s confusion; it is shared as a humorous coding fail or reaction to messy beginner code.

Objects
Tags
Source
Type
image
Size
689×800 · 87.8 KiB
Mood
sarcastic, absurd
Language
en
Added

Similar memes