Misconceptions about C conversion specifiers and some knowledge about arrays

Source: Internet
Author: User

In fact,%c in the scanf () function is not used to enter a single character, but instead to enter a set of characters.

For example:

Char a[3];scanf ("%3c", a);

Where "3" specifies the width of the input data and, of course, the width is "1",%c can indeed be used to enter a single character. But think

The format conversion of%c is simply a big mistake to enter a single character, and may produce a very serious potential bug.

The contact%nd,n Specifies the width of the input data, but unlike%NC,%nd only enters a single shaping data, which is not greater than n in width.

Review the knowledge points about the array:

When an array element is assigned a value in initialization, the remaining element system defaults to 0.

If you assign a value to a partial element in the input, the remaining element is not assigned, and the value is a random number.

The definition of an array in a formal parameter, such as Double A (double a[n]), this n is meaningless, because the parameter type Double[n],

The array name type that is invoked as an argument is indeed a double *, meaning that the argument essence here is just a pointer to the data of a double type.

It does not itself contain any information about the size of the array. The correct notation is double A (double [],int).

Misconceptions about C conversion specifiers and some knowledge about arrays

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.