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;
}