I need an urgent answer to a question: how do you convert a character in C++ into float? I need to do a float computation. I tried converting the char into integer , but even that doesnt work (i used strtoi, atoi, and char-'0'). Then my friend says even if you convert to int, the float computation of float =int/int is wrong. If you know how to , please give a short example.
Thanks for your reply, but it is actually a string. I need to convert some characters into float's and push them into a stack.
So i did something like:
d = string[a];
int temp = d- '0';
stackObject_2.push(temp);
Or, what behaves in the same way,
int temp = string [a] - '0'
stackObject_2.push(temp);
because I wanted to see that it works like that first. However, because of the string I get the stupid problem that the stack gets an extra two zeros as the first input (no idea how that happens). I have the feeling that d gets to be a string of one character and the null at the end, although i only mean it to be a character
Bookmarks