如何在domaine中从domain_cx中检索数据,一旦我在函数get_domaine(...)中尝试了以下操作,但结果不是预期的结果(0-2而不是0-2 3)。这里是我的代码char *转换为char *
#include <stdio.h>
#include <stdlib.h>
int get_domaine(char * domaine)
{
char (*ptr_dom)[10];
ptr_dom = (char (*)[10]) domaine;
printf("%s ", ptr_dom[0]); // will print
printf("%s ", ptr_dom[1]); // will not print even thought there is data.
return 1;
}
int main(int argc,char * argv[])
{
char *domaine_cx[10];
domaine_cx[0] = "0-2";
domaine_cx[1] = "3";
if(get_domaine((char *)*domaine_cx)) printf("Ok");
return EXIT_SUCCESS;
}
我编辑它,它现在编译。 – maximegir