i want to tokenize a string e.g. "5 + 3 * 2 - 4 " everytime when a " " (space) appears. the operator signs shall be saved in different named char variables. the numbers in different named float variables. e.g.
float num_1 = 5;
float num_2 = 3;
float num_3 = 2;
float num_4 = 4;
char op_1 = '+';
char op_2 = '*';
char op_3 = '-';
this is my tokenizer so far. but this can only print the numbers and operatos in console. thats not what i want.
std::vector<std::string> strings;
std::istringstream f("3 + 2 * 4 ");
std::string s;
while (std::getline(f, s, ' ')) {
std::cout << s << std::endl;
strings.push_back(s);
}
i googled this stuff for an eternity, but i never found something helpful to me. im just a beginner and most of this code i googled was too hard for me to actually understand or it was just not what i need :/