A comparison between C language sizeof and strlen

Source: Internet
Author: User

Today I saw an algorithm for the topic, said to be merged into two ordered arrays, in an orderly manner.

Look at the thought is very simple, take for granted began to knock on the program, but found a lot of small problems, these are the basis ah, prominent is the sizeof () problem.

sizeof () Gets the length of the occupied byte of a type (I actually used to get the length of the array)

Strlen gets the length of the string (I'm still used to get the length of the array)

Two times after the fall, I do not do these boring attempts, carefully look for problems.

Find the definition and start using the

sizeof (Array)/sizeof (array[0]), so that the length of the array is obtained.

There are a number of sizeof (), such as byte alignment.

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.