Note that there are some explanatory texts on larger screens.

plurals
  1. POCout not printing number
    primarykey
    data
    text
    <h2>Issue</h2> <p>I'm getting no output from a simple cout, whereas a printf will always print the number:</p> <pre><code>std::cout &lt;&lt; variableuint8; // prints nothing printf("%u", variableuint8); // prints the number </code></pre> <p>I've never run into this behavior before, and while I have a work around I would like to understand it.</p> <h2>Context:</h2> <p>Yay, pointers. So it may be a little more involved than as stated. Here's the context - I don't think it should matter, by the time cout and printf get the info it's dereferenced to a simple unsigned char. This is probably more information than needed to resolve the issue, but I wanted to be complete on the off chance that it was relevant.</p> <pre><code>typedef unsigned char UInt8; typedef unsigned short UInt16; typedef struct{ UInt8 len; // some other definitions. sizeof(DeviceNotification) &lt;= 8 }DeviceNotification; UInt8 somerandomdata[8]; DeviceNotification * notification; notification = (DeviceNotification *) somerandomdata; std::cout &lt;&lt; "Len: (" &lt;&lt; notification-&gt;len &lt;&lt; ")\n"; printf("Len: (%u)\n", notification-&gt;len); </code></pre> <p>The random data is initialized elsewhere. For this output, the first byte in the array is 0x08:</p> <h3>Output:</h3> <pre><code>Len: () Len: (8) </code></pre> <h2>Environment</h2> <ul> <li>Development machine: <ul> <li>OS X 10.6.8</li> <li>Compiler LLVM 1.7</li> <li>Xcode 3.2.6</li> </ul></li> <li>Test machine: <ul> <li>OS X 10.6.8</li> </ul></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload