Please ELI5 if possible, since i've only been coding for a few days and this is my first program! Below is a portion of my script that is supposed to interpret a single line of input that somebody enters (like "5+5" or something).
I have other operations that I want to add later that are formatted differently, which is why I'm using string instead of a switch function or something.
Anyways.. this isn't working :( So below is my logical process and maybe somebody can point out where I messed up? :)
Thank you in advance!
if (fork.find("+" && "-" && "x" && "/"))
{
size_t pos = fork.find("+" && "-" && "x" && "/"); // Defines a position at the operator symbol
string afterfork = fork.substr(pos + 1); // Cuts a substring at the operator symbol + 1
size_t beforepos = fork.find_first_of(fork); // Defines a position at the beginning of the string
string beforefork = fork.substr(beforepos); // cuts a substring at the begninning of the string
string atfork = fork.substr(pos); // cuts a substring that only has one char (the operator +, -, x, etc)
int x = stoi(beforefork.c_str()); // converts the first substring to an integer
int y = stoi(afterfork.c_str()); // converts the third substring to an integer
string operation = atfork; // converts the middle substring that only has one char to a different name.
return input(x, operation, y); // will send this information to the input function (which will do the math for the calculator).
}