Here is the problem. I'm trying to write a calculator similar to one that is in all computers. It should take values from one EditBox, make all needed calculations, and then display in another EditBox. For example: 3*6/2; result: 9; I've managed to do this:
double rezultatas = 0;
double temp = 0;
// TODO: Add your control notification handler code here
UpdateData(TRUE);
for (int i = 0; i < seka_d.GetLength(); i++)
{
if (seka_d[i] == '/' || seka_d[i] == '*')
{
if (seka_d[i] == '*')
{
temp = (seka_d[i - 1] - '0') * (seka_d[i + 1] - '0');
}
if (seka_d[i] == '/')
{
temp = (seka_d[i - 1] - '0') / (seka_d[i + 1] - '0');
}
//temp = (seka_d[i - 1] - '0') / (seka_d[i + 1] - '0');
}
if (seka_d[i] == '+' || seka_d[i] == '-')
{
if (seka_d[i] == '-')
{
temp = (seka_d[i - 1] - '0') - (seka_d[i + 1] - '0');
}
if (seka_d[i] == '+')
{
temp = (seka_d[i - 1] - '0') + (seka_d[i + 1] - '0');
}
//temp = (seka_d[i - 1] - '0') + (seka_d[i + 1] - '0');
}
if (seka_d[i] == '-')
{
temp = (seka_d[i - 1] - '0') - (seka_d[i + 1] - '0');
}
//rezultatas++;
}
result_d = temp;
UpdateData(FALSE);
It checks string seka_d for any simbols like '*','-','/','+' and the does the operation with two neighbor simbols(ex. 1+2, sums 1 and 2)(i know it doesnt work properly with multiple operations yet), but now I have to also operate with doubles, so I want to know is it possible to convert a part of string to an integer or double(ex. 0.555+1.766). Idea is to take part of string from start to a symbol(from start until '+') and from symbol to an end of string or another symbol(ex. if string is 0.555+1.766-3.445 it would take a part of string from '+' until '-'). Is it possible to do it this way?