C Language Basics

Source: Internet
Author: User

Because the insurance research machine test, so the C language looked, originally feel good, really found a few very basic to the problem will not.

1.

struct Node {    int*pnode;

This defines the alias node for struct node, which I thought pnode was defined as a node type pair pointer ... Now I know I'm stupid.

It's actually supposed to define an alias for struct node * called Pnode.

2.

About character Arrays:

char s[] = {'a'b'c ' ' D '};

This defines a character array s and initializes it. But strlen (s) refers to 5 (GCC and vs run results may be different!). ), the value of sizeof (s) is 5;

But if you define this:

Char " ABCDE ";

Here the value of strlen (s) should be also 5, and the value of sizeof (s) is 6;

The result of sizeof is different because the compiler does not require the last to add a ' \ ', so when the group applies strlen to it, different compilers may have different results.

For the latter pair of definitions, the compiler requires that the end of the group be added a '/s '.

C Language Basics

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.