C Language Bank----pointers

Source: Internet
Author: User

1. If f is a function, please explain the meaning of f () and F.

F is the address of the function, and F () is the function

2. How to understand the subscript operation of arrays?

First, offset, and then take the address.

3.int *p,*q; int a[]={10,20,30,40};  p=&a[0]; q=&a[3]; Excuse me, how much q-p equals?

%p Output is 3

%d output is 12

4. Please explain the difference between int aa (char s[]) and int aa (char *p)?

There is no difference in usage, S "" is just a reminder of the contents of the declaration as an array

5.char *p,*q;   p= "XYZ"; Q=p; May I ask Q=p; Does the assignment statement copy the characters in memory?

No

Char p,q;    P= ' a ';  Q=p; May I ask Q=p; Does the assignment statement copy the characters in memory?

Has PQ as a character variable, not a pointer

6.int a[]={1,2,3,4}; a++: Is the above statement feasible? If this is not possible, please indicate the error.

No, the address of a-headed element cannot be changed.

7.int a[]={1,2,3,4}; int *p=a+1; p++; Is the above statement feasible? If this is not possible, please indicate the error.

OK

8. How do I print out the address of the pointer?

printf ("%p\n", p);

9.int *p,**q,a=6; p=&a; q=& (&a); Is the above statement feasible? If not, please indicate the error.

No, the variable can not be taken two times address, the address does not occupy additional memory space

10. May I ask int *p; *p=10; Is the above statement correct? If the error, please indicate the error.

Not correct, *p does not point to the content

11. What is the meaning of int *p=null?

P does not have any pointing

12. Is the memory allocated when the variable is defined or when the variable is assigned?

assignment when assigning a value

13.char *p= "abcdef"; What do you mean, p[3]?

P Backward offset 3 units after indirect reference

14.char *p= "abcdef";  float *pip=3.134; Is the above statement correct? If wrong, please correct it.

Pointer is an address variable

15.char *p= "ABCD"; *p= ' B '; Is the above statement correct? If the error, please explain why.

Incorrect, cannot change the contents of a string constant

16. Define int a[10] in a file; Is it possible to declare extern int a[] In another file;(unspecified length)?

17.char c[]= "ABCDEFG"; void Fun (char ca[10]) {}; Call the function. Excuse me, is &c and &ca equal?

The actual parameters and formal parameters, the address is not the same, but the same content

are ++CA and &c[1] equal?

Not equal

is &ca[1] and &c[1] equal?

Not equal

is C and &c equal?

Equal, C is the first address of the string constant

18.int *p,a[10]={0}; For (P=&a[9];p >=&a[0];p-) {*p=1;} is there a problem with the above statement?

No

19.char *p= "ABCD";   Char c[]= "ABCD"; *p= ' B ' c[0]= ' B ' is the above statement correct?

The contents of the *p point to a string constant that cannot be changed, and the contents of C "0" can be changed

20.char a[][10]={"ABCD", "AAAA"}; Char b[2][]={"ABCD", "AAAA"}; is the above statement correct?

Incorrect, two-dimensional array B does not have a type defined

C Language Bank----pointers

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.