Chinaunix首页 | 论坛 | 博客
  • 博客访问: 67256
  • 博文数量: 18
  • 博客积分: 1435
  • 博客等级: 上尉
  • 技术积分: 195
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-23 10:22
文章分类
文章存档

2013年(3)

2011年(1)

2007年(3)

2006年(11)

我的朋友

分类: C/C++

2006-12-18 21:43:15

二维数组:
#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) |
给主人留下些什么吧!~~

chinaunix网友2009-07-19 14:42:39