C++ strings, the string cant contain the plus sign -



C++ strings, the string cant contain the plus sign -

i trying create more advanced calculator come in piece of algebra. have problem, string contains inputted doesn't test positive '+' when does.

this code tests string

for(int = 0; < line.length(); i++) { if(pos == 0 && line[i] >= '0' && line[i] <= '9' || line[i] == '.') { p1[p1p] = line[i]; // setting number current character p1p++; // position of first number } if(line[i] == '+') { pos++; operation = 1; cout << "add" << endl; } }

it never out set + unless there no space between lastly character of number , + symbol

e.g. '100+10' test positive '+' '100 + 10' wouldn't.

thanks -hugh

if guess right input info std::cin. why not read characters after first white space.

use getline() function instead.

c++ string

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -