On 1 Ott, 17:26, Diwa <shettydiwa...@gmail.com> wrote:
> Our app uses cout to print ints
>
> However on somedays, everything is in hexadecimal format
>
> "ios::hex" or "hex" does not exist in our code anywhere.
>
> Any enviromental variables whivch affect C++ iostreams
>
> Or some library setting "hex"
>
> Or is it the use of C style printfs in the code which confuses c++
> iostream?
As far as I know, the only two things that can (legally) affect the
formatting via any stream are passing a manipulator to them (such as
hex) or explicitly changing their flags.
Neither printf nor any environmental variable should affect such
formatting at all.
My pick is that some call to some external library is directly
affecting cout.
You can check out cout's flags after those calls to find the offending
call (adding a "cout << dec;" after that particular call, to solve the
problem) otherwise you can explicitly put cout in decimal mode every
time before outputting your ints - which should be the correct habit:
never make assumptions on the current state of a shared resource,
either check it or set it to the state you want it to be.
Hope that helps. Feel free to clarify and ask again if I misunderstood
your issue.
Have good time,
Francesco
--
Francesco S. Carta, hobbyist
http://fscode.altervista.org