printf does what the format sting tells it to do:by counting_pine (no login)"%d" will take the input and always see it as a signed integer. In fact, you'll get the same result here if you take away the '-' sign. Try doing a test in C++ with std::cout, and see what happens there. from IP address 86.164.34.141 |
| Response Title | Author and Date |
| With std::cout, it prints positive | qbguy on Apr 7 |
| gcc defaults to C89, and C++98 isn't any better regarding this aspect. | rpgfan3233 on Apr 7 |