c++unsigned Char Output problem

Source: Internet
Author: User

unsigned char range is 0~255, when using cout output to display the number words remember to make an int forced conversion can be, otherwise are the output of the character, in addition to all the comparison converted to an integer in the comparison bar

In addition, in recent projects due to the multiple use of dynamic memory allocation, the code uses two allocation methods to briefly say.

Regardless of the standard of the two, the assignment with new does not have to be multiplied by sizeof, but if it is allocated by malloc, it is not done according to this criterion, and we use unsigned when malloc allocates it. Char to allocate not multiplied by sizeof also passed, is because sizeof (unsigned char) is exactly 1, so happened to avoid this error, so after allocating memory as far as possible with new bar, with malloc remember by sizeof.

New int [Vbm->width * vbm->height]; // samplesVbm->nummatch = (int32_t*)mallocsizeof(int32_t)); // How many samples match

c++unsigned Char Output problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.