关于传递数组参数给函数的问题.
#include "conio.h"
#include "stdio.h"
#include "stdlib.h"
void foo_ca(char ss[]);
void foo_pc1(char* ss[]);
void foo_pc2(char** pa);
void foo_ppc(char** pa);
int main(int argc, char** argv)
{
char ca[2][30] = {"The first element!\n\0","The second element!\n\0"};
char* pc[2] = {"The first element!\n\0","The second element!\n\0"};
char** ppc = (char**)new char[10][50];
ppc[0] = "The first element!\n";
ppc[1] = "The second element!\n";
foo_ca(ca); //failed,Why?
foo_pc1(pc);
foo_pc2((char**)&pc);
foo_ppc(ppc);
system("PAUSE");
return -1;
}
void foo_ca(char ss[])
{
printf("\nfoo_cc:\n");
printf(&ss[0]);
printf(&ss[1]);
}
void foo_pc1(char* ss[])
{
printf("\nfoo_pc1:\n");
printf(ss[0]);
printf(ss[1]);
}
void foo_pc2(char** ss)
{
printf("\nfoo_pc2:\n");
printf(ss[0]);
printf(ss[1]);
}
void foo_ppc(char** ss)
{
printf("\nnfoo_ppc:\n");
printf(ss[0]);
printf(ss[1]);
}
到底要怎么样才能把 ca 传给 foo_ca() 呢?