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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:30:30+00:00 2026-06-14T22:30:30+00:00

Reading the C++ Primer 5th edition book, I noticed that a signed char with

  • 0

Reading the C++ Primer 5th edition book, I noticed that a signed char with a value of 256 is undefined.
I decided to try that, and I saw that std::cout didn’t work for that char variable. (Printed Nothing).

But on C, the same thing
signed char c = 256;
would give a value 0 for the char c.

I tried searching but didn’t find anything.

Can someone explain to me why is this the case in C++?

Edit: I understand that 256 is 2 bytes, but why doesn’t the same thing as in C, happen to C++?

  • 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-14T22:30:31+00:00Added an answer on June 14, 2026 at 10:30 pm

    Edit: See T.C.’s answer below. It’s better.

    Signed integer overflow is undefined in C++ and C. In most implementations, the maximum value of signed char, SCHAR_MAX, is 127 and so putting 256 into it will overflow it. Most of the time you will see the number simply wrap around (to 0), but this is still undefined behavior.

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

Sidebar

Related Questions

While reading C++ Primer Plus 5th edition, I saw this piece of code: cin.get(ch);
I am reading the chapter function templates of C++ Primer 3rd edition , and
I am reading the book C++ Primer and at the file input output chapter
I'm reading a book, the Primer guide to C++. I think I got the
I am just learning programming really, and, while reading C++ Primer Plus (5th Ed.),
I'm relatively new to C++, I start by reading C++ Primer 4th edition .
I am reading Chapter 17 of C Primer Plus, and here is the code
Reading the Scala by Example book and there is this example when Martin explains
Probably an extremely simple answer to this extremely simple question: I'm reading C Primer
I'm reading through an example in primer and something which it talks about is

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.