int **ptr = new int*[N];
for ( i = 0; i < N; i++)
ptr[i] = new int[N];
#include
#include
using namespace std;
void print_char(char* array[],int len);//考試,大提示函數(shù)原形聲明
void main(void)
{
//----段1----
char *a[]={"abc","cde","fgh"};//字符指針數(shù)組
char* *b=a;//定義一個(gè)指向指針的指針,并賦予指針數(shù)組首地址所指向的第一個(gè)字符串的地址也就是abc\0字符串的首地址
cout<<*b<<"|"<<*(b+1)<<"|"<<*(b+2)< //----段2----
char* test[]={"abcgdf","cde","fgh","dsadsgasff"};//注意這里是引號(hào),表示是字符串,以后的地址每加1就是加4位(在32位系統(tǒng)上)
int num=sizeof(test)/sizeof(char*);//計(jì)算字符串個(gè)數(shù)
int **t;
cout< print_char(test,num);
cin.get();
}
void print_char(char* array[],int len)//當(dāng)調(diào)用的時(shí)候傳遞進(jìn)來(lái)的不是數(shù)組,而是字符指針?biāo)考?也就是加上sizeof(char*)的長(zhǎng)度
{
for(int i=0;i {
cout<<*array++< }
}
運(yùn)行結(jié)果:
abc|cde|fgh
16
4
4
abcgdf
cde
fgh
dsadsgasff
for ( i = 0; i < N; i++)
ptr[i] = new int[N];
#include
#include
using namespace std;
void print_char(char* array[],int len);//考試,大提示函數(shù)原形聲明
void main(void)
{
//----段1----
char *a[]={"abc","cde","fgh"};//字符指針數(shù)組
char* *b=a;//定義一個(gè)指向指針的指針,并賦予指針數(shù)組首地址所指向的第一個(gè)字符串的地址也就是abc\0字符串的首地址
cout<<*b<<"|"<<*(b+1)<<"|"<<*(b+2)<
char* test[]={"abcgdf","cde","fgh","dsadsgasff"};//注意這里是引號(hào),表示是字符串,以后的地址每加1就是加4位(在32位系統(tǒng)上)
int num=sizeof(test)/sizeof(char*);//計(jì)算字符串個(gè)數(shù)
int **t;
cout<
cin.get();
}
void print_char(char* array[],int len)//當(dāng)調(diào)用的時(shí)候傳遞進(jìn)來(lái)的不是數(shù)組,而是字符指針?biāo)考?也就是加上sizeof(char*)的長(zhǎng)度
{
for(int i=0;i
cout<<*array++<
}
運(yùn)行結(jié)果:
abc|cde|fgh
16
4
4
abcgdf
cde
fgh
dsadsgasff