当前位置:网站首页>Common interview questions

Common interview questions

2022-06-09 05:18:00 wolf_ break

remarks

You can also refer to the articles on arrays and functions
Array :https://blog.csdn.net/wolf_break/article/details/78320138

function :https://blog.csdn.net/wolf_break/article/details/78320460

Pointer subtraction

Pointers of the same type can be mutually subtracted

    int a[] = {
   2,4,5};
    int *p = a;
    int *q = &a[2];


    cout << a[q-p]; //5
    //q-p Namely  q Inside address minus p Inside address , Besides sizeof(int), The result is 2

A function pointer

 A function pointer

Classical problems :
One has 10 An array of pointers , The pointer points to a function , This function has one int Parameters , return int type .
answer :
int (*p[10])(int)


The pointer of the pointer

example 1:

char *str[] ={
   "123","6","432432"};
char **p = str;
cout <<  *p << endl;    //6
原网站

版权声明
本文为[wolf_ break]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203021429257476.html