Original Post
Basically, I have a and b (floats), I add them up and divide by zero - that's c (float). Now, I tell std::cout to print c and it prints 1.#INF Ok, here is my code: The strange part is that, if I replace a and b by 1 (but not both by 1.0, then it will work fine), then the compiler will get me an error in Visual C++ Express, and in Code::blocks, it will compile but it will crash. My processor is a Pentium 4, 3.0 Ghz. Does anybody know what's going on?
#include <iostream>
int main()
{
float a;
float b;
float c;
std::cout << "type a number" << std::endl;
std::cin >> a;
std::cout << "Great! now type another one" << std::endl;
std::cin >> b;
c = (a (plus) b)/0; //the problem here is that the forum source tags won't display the 'plus sign', but there was suposed to be one here.
std::cout << "c is: " << c << std::endl;
std::cin >> b;
return 0;
}