How to print byte array in hexadecimal - c++ I have a piece of code here: #include &lt;iostream&gt; #include &lt;iomanip&gt; using namespace std;  int main(void) {         unsigned char bytes[] = {0x43,0x4d,0x30,0x30,0x0f,0x0D};      std::cout &lt;&lt; std::hex &lt;&lt; bytes[0] &lt;&lt;std::endl;     }  The above program is printing C to command line. How can I make the program to print 43 to commandline. My OS is Windows 10, 64 bit.
how do I print an unsigned char as hex in c++ using ostream? I want to work with unsigned 8-bit variables in C++.  Either unsigned char or uint8_t do the trick as far as the arithmetic is concerned (which is expected, since AFAIK uint8_t is just an alias for unsigned char, or so the debugger presents it.  The problem is that if I print out the variables using ostream in C++ it treats it as char.  If I have:  unsigned char a = 0; unsigned char b = 0xff; cout &lt;&lt; "a is " &lt;&lt; hex &lt;&lt; a &lt;&lt;"; b is " &lt;&lt; hex &lt;&lt; b &lt;&lt; endl;   then the output is:  a is ^@; b is 377   instead of   a is 0; b is ff   I tried using uint8_t, but as I mentioned before, that's typedef'ed to unsigned char, so it does the same.  How can I print my variables correctly?  Edit: I do this in many places throughout my code.  Is there any way I can do this without casting to int each time I want to print?
What does one second after big bang mean? Consider the following statement:     Hadron Epoch, from $10^{-6}$ seconds to $1$ second: The temperature of the   universe cools to about a trillion degrees, cool enough to allow   quarks to combine to form hadrons (like protons and neutrons).   What does it mean to say "from $10^{-6}$ seconds to $1$ second"?   How is time being measured?  One particle might feel just $10^{-20}\ \mathrm s$ having passed and another could feel $10^{-10}\ \mathrm s$ having passed.   Is saying "1 second after the big bang" a meaningful statement? Can I use javascript to dynamically change a video's source? Hyperlinks to web sites using anchors sometimes don't work A function $f: \mathbb{R} \to \mathbb{R}$ is said to have the intermediate-value property if for any $a$, $b$ and $\lambda \in [f(a),f(b)]$ there is $x \in [a,b]$ such that $f(x)=\lambda$.  A function $f$ is injective if $f(x)=f(y) \Rightarrow x=y$.  Now it is the case that every injective function with the intermediate-value property is continuous. I can prove this using the following steps:   An injective function with the intermediate-value property must be monotonic. A monotonic function possesses left- and right-handed limits at each point. For a function with the intermediate-value property the left- and right-handed limits at $x$, if they exist, equal $f(x)$.   I am not really happy with this proof. Particularly I don't like having to invoke the intermediate-value property twice.  Can there be a shorter or more elegant proof? Existence in ZF of a set with countable power set How can I charge my iPhone without waking up my MacBook Pro? Showing that $Q_n=D_n+D_{n-1}$ Let $T_n$ be the set of permutations of $\{1,2,\ldots,n\}$ which do not have $i$ immediately followed by $i+1$ for $1\le i\le n-1$; in other words, let \begin{align} T_n=\{\sigma \in S_n: \sigma(i)+1\ne\sigma(i+1) \text{ for all } 1\le i\le n-1\} . \end{align} Let $Q_n$ be the number of elements of $T_n$.    Let $D_n$ be the number of  of $\{1,2,\ldots,n\}$.  It is not hard to show algebraically that $Q_n=D_n+D_{n-1}$, but I am having difficulty coming up with a combinatorial argument to show why this is true.  (I believe there are $D_{n-1}$ elements of $T_n$ that leave $n$ fixed, and $D_n$ elements of $T_n$ that move $n$, but I don't know how to justify this combinatorially.) What are the dangers of accepting gifts from unknown accounts on Steam? A user named 'steamfairy1' gifted me a game on Steam. I don't know this user, their profile shows no games, no friends and zero hours played. The profile of 'steamfairy1' was created the day I received the gift.  It very much looks like a scam, but I can't figure out how the scam is supposed to work. What's the worst thing that could happen if I accept the gift? Any idea what the trick here is? It could be just a random act of kindness and I'm just paranoid…  I contacted the Steam support, but they were unhelpful as usual: responding in the wrong language and with a canned one-liner that didn't make a whole lot of sense or had much to do with my question.  Keywords (not really tags, but I want this to be searchable): steamfairy, steam fairy How do I install VMware Player 4.0.3 (and patch the installer to work on my 12.04 system)? From a collection of short stories I read at least 30 years ago. :/  This is going to be incredibly vague, so apologies in advance.  A human and alien (blob/octopus-like...I think) from warring races are captured by an unidentified higher intelligence and put in an enclosure (more like a zoo habitat rather than a prison cell). They are separated by an invisible barrier and can see each other.  I think they were both trying to escape or trying to figure out how they could kill the other first. There was a bulldozer/loader type vehicle they could use at one point to build a shelter (or something).  I believe they were crafting makeshift weapons as well. There was no communication between the two as far as I remember.  The main tension in the story seemed to be was the race to get to the other first.  This has been stuck in my head forever. I know its a very common theme.  The short stories may have included Asimov. Can one attack for damage after having grappled an opponent? The grappling rules sure are... light. Supposing one has an Extra Attack:   Assuming one has successfully grappled an opponent with one's first attack, can one then perform a normal attack action with one's Extra Attack? Against the grappled opponent or any opponent within reach? Limitations on weapons (e.g. one-handed only)? Assuming one has successfully grappled an opponent with one's first attack, can one's grappled opponent (now with move 0) perform a normal attack action? Against you or against any one in reach? Do advantage and disadvantage (along the lines of restraint) come into play? Are there grappling-specific attacks for damage (e.g. choke-hold)? I wanted a simple environment for making lists of equations, so I made one that includes an equation and a split environment. The code won't compile and the error seems unrelated. The most pressing thing I noticed was the &quot;You can't use `\end' in internal vertical mode.&quot; The problem is definitely the split environment. Here is a MWE. \documentclass{article} \usepackage{amsmath}  \newenvironment{env}     {\begin{equation}\begin{split}}     {\end{split}\end{equation}}  \begin{document} \begin{env}     x \end{env} \end{document}  If I remove the split environment from env, everything compiles just fine. Additionally, If the following example compiles just fine. What is the problem then? \documentclass{article} \usepackage{amsmath}  \begin{document} \begin{equation} \begin{split}     x \end{split} \end{equation} \end{document}  Here is the LaTeX error upon running the MWE. math.tex|11 error| LaTeX Error: \begin{split} on input line 9 ended by \end{env}. math.tex|12 error| LaTeX Error: \begin{equation} on input line 9 ended by \end{document}. math.tex|12 error| Missing $ inserted. math.tex|12 error| Missing } inserted. math.tex|12 error| Missing } inserted. math.tex|12 error| Missing } inserted. math.tex|12 error| Missing \cr inserted. math.tex|12 error| Missing { inserted. math.tex|12 error| Missing { inserted. math.tex|12 error| Extra }, or forgotten $. math.tex|12 error| Missing $ inserted. math.tex|12 error| Missing } inserted. math.tex|12 error| You can't use `\end' in internal vertical mode. math.tex|12 error| LaTeX Error: \begin{equation} on input line 9 ended by \end{document}. math.tex|12 error| Missing } inserted. math.tex|12 error| Missing $ inserted. math.tex|12 error| Display math should end with $$. math.tex|| Emergency stop. math.tex|| ==&gt; Fatal error occurred, no output PDF file produced! Add a way to see where links go in Android app I think it would be good to have a way for the user to view the target URL of a link before following it. I'm pretty sure that I'm not the only one who dislikes blind-clicking -tapping links.   When I use SE in the mobile browser, I routinely long-press links to find out where they go before following them. I wish I could do the same thing in the app, with the same or a similar method.  (It's important that this won't conflict with text selection, since you can't long-press on links to select them now anyway.) How to access object attribute given string corresponding to name of that attribute Combinations of sets raised to the power of a prime modulus: $\binom{p^{\alpha}-1}k \equiv (-1)^k \pmod p$ Should flagging a question for closure prevent close-voting? Back in April, I flagged a post as "not a real question".  The post was subsequently closed and reopened, then closed again and finally just reopened a 2nd time a short time ago.  I still firmly believe the post is not acceptable for SO, so I went to use my recently acquired close vote privilege and was greeted with the following messsage:    I specifically clicked close and not flag (and figuring I just clicked in error, I tried again and got the same message).  I do understand that, in the new closing system, flagging for closure is treated very much like a close vote (since it throws it to the close vote queue) except no vote is actually recorded.  My issue is why should by flag be counted as a close vote when I never actually voted to close. I want the QED symbol to be 1 line lower at the end of proof Just as my title says, I would prefer to have my qed symbol to be 1 line lower than the last line of my proof. By default its on the same line and aligned to the right.   How can I achieve this?  EDIT: See below code for an example:  \documentclass[11pt,a4paper]{article} \usepackage[margin=3cm]{geometry} \usepackage[english]{babel} \usepackage{amsmath, amsthm} \begin{document}  \begin{proof}     Hello there good chap! I'll put in another line here just to be sure its clear what I mean. \end{proof}    \end{document} My laptop (running Win10) repeatedly "steals" the bluetooth connection for my headphones while they're connected to my phone. The only way I've been able to prevent the headphones' connection from switching to the laptop is to play some media or make a phone call immediately after reconnecting to my phone, or to unpair the headphones from the laptop.  The headphones are Plantronics Backbeat Go 2, and the specifications from the Plantronics product page give the following information for the Bluetooth entry:      Bluetooth v2.1:   A2DP 1.2, AVRCP, HFP v1.5, HSP v1.1   Thanks in advance! Installing MinionPro fonts on Ubuntu 10.04 running TexLive 2012 I followed the instructions to install MinionPro fonts from this website.   However, when I tried to run the tex file at the bottom, I have this error message:  ! LaTeX Error: File `MinionPro.sty' not found.   Running the command kpsewhich MinionPro.sty gives the following output:  /usr/local/share/texmf/tex/latex/MinionPro/MinionPro.sty   So the system knows where MinionPro.sty is, so why can't the file compile? Which is the best workflow to follow when texturing and importing textures from Substance Painter? So, I'm planning to texture a model using Substance Painter and will render it using the Cycles Render Engine. I will be also using the Principle Shader, heavily, to achieve realistic renders. So, which workflow in Substance Painter so that the textures are accurately rendered in Blender? Specular-Glossy? Or should I go with Metalic-Roughness?