Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8460121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:31:09+00:00 2026-06-10T13:31:09+00:00

So I have a two char array unsigned char v[2]; I want to show

  • 0

So I have a two char array

unsigned char v[2];

I want to show the value of v[0] as a number from 0 to 255 but

cout << v[0] << endl; //prints some garbage

cout << (void*)v[0] << endl; //prints the right thing but in hex

So I tried

cout << (int)v[0] << endl;

or

printf("%d\n", v[0]);

This shows exactly what I wanted but I don’t like it at all. Also what I don’t understand at all is why this doesn’t work:

cout << reinterpret_cast<int>(v[0]) << endl; //compiler error
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:31:10+00:00Added an answer on June 10, 2026 at 1:31 pm

    (In layman’s terms) reinterpret_cast is used to interpret the bits of an object as another type in an implementation-defined manner. You don’t want that: you want a conversion (from char to int). Use static_cast instead.

    (All possible uses of reinterpret_cast are listed in 5.2.10; this is not one of them.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have two char variables, and later on I want to concatenate
I have two variables: char charTime[] = TIME; char buf[] = SOMETHINGELSE; I want
So, I have two types at the moment: const unsigned char* unencrypted_data_char; string unencrypted_data;
My task consists of two parts. First I have to create globbal char array
I have a binary array char buffer[N]; which contains two bytes to be interpreted
I have a two-dimensional char array declared with four strings. private static string string1
i have tested two different varianat of similary code ,suppose i have char array
I have two arrays of chars, allocated as follows: unsigned char *arr1 = (unsigned
I have two tables in a MySql DB: items id (char) name (varchar) description
I have two pointers, char *str1; int *str2; If I look at the size

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.