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 7508769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:44:08+00:00 2026-05-29T22:44:08+00:00

I am facing a strange issue, working on my mac osx lion (under xcode4/clang,

  • 0

I am facing a strange issue, working on my mac osx lion (under xcode4/clang, though it is reproducible with gcc4.2).

It seems, that I can not assign any value above 127 for a unsigned char variable. So, when I assign

v = (unsigned char) 156;

or, simply

std::cout << (unsigned char) 231 << std::endl;

my program does not produce any output.

When I run this code

std::cout << "Unsigned chars range up to " << UCHAR_MAX << std::endl;

I get the following output:

Unsigned chars range up to 255

However, when I run something like this, the program generates outputs up to some different arbitrary value (such as c = 114, c = 252, etc etc) each time.
for(unsigned char c = 0; c < CHAR_MAX; c++)
std::cout << “c = ” << 2*c << std::endl;

Changing the CHAR_MAX to UCHAR_MAX, the program ends without an output again 🙁

Thanks in advance

  • 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-05-29T22:44:09+00:00Added an answer on May 29, 2026 at 10:44 pm

    cout is converting the numeric value to a character from the character set (Well, it’s attempting to … when you don’t see anything it’s not a valid character for your charset, and technically it’s the terminal that’s deciding this).

    Cast it to unsigned int instead.

    Edit to add: ildjarn makes a very valid point in his comment to your question; if you ran this in the debugger you’d see that the value was indeed what you expected.

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

Sidebar

Related Questions

We are facing a strange issue while sending email. It seems that the new
I am facing a very strange issue. I have a SharePoint webpart that displays
I am facing strange issue with our WCF service. The same code was working
I am facing strange issue. I have wep-part that reads data from user's profile.
I am working on a C# application and facing a strange issue here. I
While working with Jquery Mobile I am facing a strange issue. Jquery Mobile adds
I am facing a very strange issue in X-Cart, I am working on localhost.
I am facing strange issue on Windows CE: Running 3 EXEs 1)First exe doing
I'm facing a strange issue, I'm trying to localize a website, so i converted
I'm facing a rather strange Issue when trying to load data from an XML-Webservice.

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.