| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 376 人关注过本帖
标题:二级指针的问题,用指针传递函数参数,亲们来看看,解释一下
只看楼主 加入收藏
吴小杰
Rank: 3Rank: 3
来 自:。。。。。。
等 级:论坛游侠
帖 子:58
专家分:107
注 册:2011-11-11
结帖率:100%
收藏
 问题点数:0 回复次数:1 
二级指针的问题,用指针传递函数参数,亲们来看看,解释一下
#include <stdio.h>  
#include"stdlib.h"

#define TRUE 1  
#define FALSE 0  
#define LENGTH 10  
  
int find_char( char *strings[], int value)  
{  
    int i=0;
    while( strings[i] != NULL)  
    {  
 
        while( *strings[i] != '\0')  
        {  
//            printf("func1-%s  2-%s 3-%s\n", strings[0], strings[1],strings[2]);

            if( *strings[i]++ == value )  
                return TRUE;  
        }  
        i++;
    }  
    return FALSE;  
}  

  
void main()  
{  
    char* str[LENGTH] = {"hello", "world","kkky",NULL};  
    char ch = 'w';  
  
    printf("1-  %s 2-  %s 3-%s \n", str[0], str[1],str[2]);  
  
    if( find_char(str, ch) == TRUE )  
    {  
        printf("%c was found!\n", ch);  
    }  
    else  
    {  
        printf("%c was not found!\n", ch);  
    }  
      
     printf("The string now is \"%s %s %s\"\n", str[0], str[1],str[2]);  
    system("pause");
}
图片附件: 游客没有浏览图片的权限,请 登录注册
   为什么hello这个字符串不显示呢??????

[此贴子已经被作者于2015-10-19 20:06编辑过]

2015-10-19 18:13
吴小杰
Rank: 3Rank: 3
来 自:。。。。。。
等 级:论坛游侠
帖 子:58
专家分:107
注 册:2011-11-11
收藏
得分:0 
#include <stdio.h>  
#include"stdlib.h"

#define TRUE 1  
#define FALSE 0  
#define LENGTH 10  
  
int find_char( char **strings, int value)  
{  
    while( *strings != NULL)  
    {  
 
        while( **strings != '\0')  
        {  
//            printf("func1-%s  2-%s 3-%s\n", strings[0], strings[1],strings[3]);

            if( *(*strings)++ == value )  
                return TRUE;  
        }  
        strings++;
    }  
    return FALSE;  
}  

  
void main()  
{  
    char* str[LENGTH] = {"hello", "world","kkky",NULL};  
    char ch = 'k';  
  
    printf("1-  %s 2-  %s 3-%s \n", str[0], str[1],str[2]);  
  
    if( find_char(str, ch) == TRUE )  
    {  
        printf("%c was found!\n", ch);  
    }  
    else  
    {  
        printf("%c was not found!\n", ch);  
    }  
      
     printf("The string now is \"%s %s %s\"\n", str[0], str[1],str[2]);  
    system("pause");
}



http://blog.

[此贴子已经被作者于2015-10-19 20:06编辑过]

2015-10-19 18:13
快速回复:二级指针的问题,用指针传递函数参数,亲们来看看,解释一下
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012408 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved