No.1 _ sizeof and strlen

Source: Internet
Author: User

= [Note] =
Programming Language is just a tool for us to communicate with computers and let computers realize our creative ideas. It can and encourages us to gain an in-depth understanding of a language, but never indulge in the tip of a language, be sure to grasp the degree between the two
This post is occasionally serialized, and provides a basic question in the form of a test paper for your consideration and discussion. The analysis of the question will be provided in the next updated post, in this case, I hope that my friends who are not clear about the problem will have time to think about and discuss it. I hope you can get some insights from these posts.

The problem in the post is some of the syntax or relatively obscure program problems I encountered during my study of C \ C ++. I have my own summary, there are also some classic resolutions found on the Internet. I would like to share them with you and hope they can play a leading role.

If you find any problems during reading, please notify me in time and I will correct them in time to avoid misleading everyone. Thank you very much ^_^

[No.1 difference between the sizeof keyword and strlen in determining the length of a C string]

[Question No. 1]
Enter the values of the following expressions in sequence (values: errors and uncertain values ):
Copy content to clipboard
Code:

Char * str_1 = "12345 ";
Char str_2 [] = "12345 ";
Char str_3 [5] = {'1 '};
Char str_4 [5] = {'1', '2', '3', '4', '5 '};

Expression value
Sizeof (str_1 )________
Sizeof (* str_1 )________
Strlen (str_1 )________
Sizeof (str_2 )________
Strlen (str_2 )________
Sizeof (str_3 )________
Strlen (str_3 )________
Sizeof (str_4 )________
Strlen (str_4 )________
Strlen (* str_1 )________

If you have any questions, please feel free to come here for discussion and exchange, and learn and make progress together.

This article is from the "Bill_Hoo" blog

Related Article

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.