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;//定義一個指向指針的指針,并賦予指針數(shù)組首地址所指向的第一個字符串的地址也就是abc\0字符串的首地址
cout<<*b<<"|"<<*(b+1)<<"|"<<*(b+2)< //----段2----
char* test[]={"abcgdf","cde","fgh","dsadsgasff"};//注意這里是引號,表示是字符串,以后的地址每加1就是加4位(在32位系統(tǒng)上)
int num=sizeof(test)/sizeof(char*);//計算字符串個數(shù)
int **t;
cout< print_char(test,num);
cin.get();
}
void print_char(char* array[],int len)//當(dāng)調(diào)用的時候傳遞進來的不是數(shù)組,而是字符指針他每加1也就是加上sizeof(char*)的長度
{
for(int i=0;i {
cout<<*array++< }
}
運行結(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;//定義一個指向指針的指針,并賦予指針數(shù)組首地址所指向的第一個字符串的地址也就是abc\0字符串的首地址
cout<<*b<<"|"<<*(b+1)<<"|"<<*(b+2)<
char* test[]={"abcgdf","cde","fgh","dsadsgasff"};//注意這里是引號,表示是字符串,以后的地址每加1就是加4位(在32位系統(tǒng)上)
int num=sizeof(test)/sizeof(char*);//計算字符串個數(shù)
int **t;
cout<
cin.get();
}
void print_char(char* array[],int len)//當(dāng)調(diào)用的時候傳遞進來的不是數(shù)組,而是字符指針他每加1也就是加上sizeof(char*)的長度
{
for(int i=0;i
cout<<*array++<
}
運行結(jié)果:
abc|cde|fgh
16
4
4
abcgdf
cde
fgh
dsadsgasff