just put the strings in a vector: vector<string> ay; >>Oh and just for curiosity, in what manner does strtok modifies the string?
It replaces the separator token (such as a space or a comma) with '\0' then returns a pointer to the beginning of that segment of the character array. Therefore you can not pass it a string literal.
Thanks Dragon. Even though I don't know anything about vectors I would look into it. But maybe you can help me. I searched the find() and substr() function and I wasn't able to split the string. Maybe you can show an example....sorry fr bothering you again.
If you're up to getting to grips with Qt, the QString class has a comprehensive range of extra methods that don't feature in std::string . One of these is split() . The advantage of this method is that Qt's split() function accepts all kinds of things, including regular expressions. It's a lot of baggage if you only want something simple, but it's all there if you want a very complete way of doing it, it's there!
There is also a Boost library called string algorithms that also has a split function.
Well here is the program I wanted to implement the spliting of the string.
So here is how it should work: It should accept a string in which there is a full operation (ex. 23 + 34) it should split the string into three parts. The first and the third part should be the numbers and the second should be the operation sign. Then it should convert the first and third string into a double number (using atof). Then use the if statement and depending on the sign it should add, multiply, substract or divide the numbers.
There are a couple of errors (too long to copy, but most of them repeat). So please compile it.
Probably there are some stupid errors because I am a begginer... sorry.
WAIT: I found some erros. I will fix them and then if had another problem, I will post it