Getting Weird Symbols from vector output

I'm trying to take a line of input (with spaces) and put it in a vector<string> so that I can access each element to eventually use in a calculator fucntion. I have it implemented so that it can detect which elements are numbers and store them in the vector. Unfortunately, when I try to add other things to the code, such as the ability to detect operators, it adds weird symbols to the end of the number elements (most notably a hashtag, along with a weird blurry square on occasion)

This is what I have so far, with the only the '+' operator being detected thus far. Does anyone have any idea what I'm doing wrong?

#include <iostream>
#include <vector>
#include <sstream>
#include <string>
#include <cctype>
using namespace std;

int main(){
	string input = " ";
	getline(cin, input);
	vector<string> equation;
	for (int i; i < input.size();) {
		char el = input[i];
		if (isdigit(el)) {
			bool number = true;
			int j = i;
			int k = 1;
			while (number == true) {
				char check = input[j];
				if(isdigit(check)) {
					k++;
					j++;
				}
				else {
					number = false;
				}
			}
			char temp[k];
			k = 0;
			for (i; i < j; i++) {
				char put = input[i];
				temp[k] = put;
				k++;
			}
			string enter(temp);
			equation.push_back(enter);
		}
		else if (el == '+') {
			equation.push_back("+");
			i ++;
		}
		else {
			i++; 
		}
	}
}
Last edited on
Topic archived. No new replies allowed.