指向指针的指针相关

1.

char* buf1[9] = {"hello", "bestwish"};

buf1+=9;

strlen(buf1)    ==  ?


2.

int* i[10];
int(*j) [10];

名词解释:

sizeof(i)  ==  ?

sizeof(j)  ==  ?


/* 
 * File:   main.cpp
 * Author: vicky
 * Email:  eclipser@163.com
 */
#include <iostream>
#include <string.h>

/*
 * 
 */
int main(void) {
        char* buf1[9] = {"hello", "bestwish"};
        char* p1 = buf1[0];
        std::cout << p1 << std::endl;
        std::cout << p1 + 10 << std::endl;
        std::cout << strlen(p1 + 10) << std::endl;

        std::cout << "---------------------------" << std::endl;

        char buf2[2][9] = {"hello", "bestwish"};
        char* p2 = buf2[0];
        std::cout << p2 << std::endl;
        std::cout << p2 + 10 << std::endl;
        std::cout << strlen(p2 + 10) << std::endl;


        std::cout << "---------------------------" << std::endl;

        char* names[10] = {"jack", "vicky", "lucy", "lily", "tom", "tony", "nacy", "bill", "anni", "ashi"};
        char** pnames = names;
        for (int i = 0; i < 10; i++)
                std::cout << *pnames++ << std::endl;
        return 0;
}

hello
wish
4
---------------------------
hello
estwish
7
---------------------------
jack
vicky
lucy
lily
tom
tony
nacy
bill
anni
ashi

/* 
 * File:   main.cpp
 * Author: vicky
 * Email:  eclipser@163.com
 */
#include <iostream>

/*
 * 
 */
int main(void) {

        int* i[10];
        int(*j) [10];
        
        std::cout << sizeof(i) << std::endl; // 80    32位: 40
        std::cout << sizeof(j) << std::endl; // 8     32位: 4
        
        return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值