二维数组:
#include
int myprint(char str[][20],int len);
int main(){
int len=3;
char str[][20]={
"this is the test1",
"this is the test2",
"this is the test3",
};
myprint(str,len);
return 0;
}
int myprint(char (*str)[20],int len)
{
int i;
for(i=0;i
printf("%s\n", str[i]);
return 0;
}
指针数组:
方法一:
#include
int myprint(char *str,int len);
int main(){
int len=3;
char *str[]={
"this is the test1",
"this is the test2",
"this is the test3",
};
myprint(str,len);
return 0;
}
int myprint(char *str,int len){
int i;
for(i=0;i
printf("%s",str[i]);
return 0;
}
方法二:
#include
int myprint(char *str[],int len);
int main(){
int len=3;
char *str[]={
"this is the test1",
"this is the test2",
"this is the test3",
};
myprint(str,len);
return 0;
}
int myprint(char *str[],int len){
int i;
for(i=0;i
printf("%s",str[i]);
return 0;
}
方法三:
#include
int myprint(char *str[3],int len);
int main(){
int len=3;
char *str[3]={
"this is the test1",
"this is the test2",
"this is the test3",
};
myprint(str,len);
return 0;
}
int myprint(char *str[3],int len)
{
int i;
for(i=0;i
printf("%s\n", str[i]);
return 0;
}
阅读(1582) | 评论(1) | 转发(0) |