zoukankan      html  css  js  c++  java
  • The example program of C on point

    计划一:
    #include<stdio.h>
    
    #define     N_VALUES        5
    
    int main( void )
    {
        float values[N_VALUES];
        float *vp;
    
        for( vp = &values[0]; vp < &values[N_VALUES]; )
            *vp++ = 0;
    
        for( vp = &values[N_VALUES]; vp > &values[0]; )
            *--vp =0;
    
        for( vp = &values[N_VALUES]; vp >= &values[0]; vp-- )
            *vp = 0;
        //不建议使用 数组下标越界
        //标准同意指向数组元素的指针与最后一个元素内存位置的指针进行比較
        //不同意第一个元素和之前内存位置的指针比較
    
        return 0;
    }
    
    程序二:
    /*
    **Programe6.1
    **计算一个字符串的函数
    */
    #include<stdio.h>
    int strlen(char *string)
    {
        int lenth=0;
        while(*string++!='')
            lenth++;
        return lenth;
    }
    int main(void)
    {
        char *string = NULL;
        string="zxczxc";
        printf("%d",strlen(string));
        return 0;
    }
    

    自己写库函数 真好玩~

    程序三:

    /*
    **Programe6.2 在一组字符串中查找 版本号1
    **给定一个指向以NULL结尾的指针列表的指针。在列表的字符串中查找一个特定的字符。
    */
    
    #include<stdio.h>
    #define     TRUE    1
    #define     FALSE   0
    
    int find_char( char **strings, char value )
    {
        char *string;   //我们当前源字符串
    
        /*
        **对于列表中每一个字符串的处理
        */
        while( ( string = *strings++ ) !=NULL )
        {
            /*
            **遍历每一个字符串 是否为目标字符串
            */
            while( *string != '' )
            {
                if( *string ++ == value)
                    return TRUE;
            }
        }
        return FALSE;
    }
    int main( void )
    {
        char* str[3][10]={"sdf","sdfdhf","fdghdf"};
        int result = find_char(str[0],'x');
        printf("%d",result);
        return 0;
    }
    
    一个指向数组确实无法使用   瞎蒙 实际测试的~

  • 相关阅读:
    MVC3 Razor模板引擎
    Razor引擎学习:RenderBody,RenderPage和RenderSection
    Lambda表达式详解
    MVC的重定向页面的跳转
    dataSet==>Ilist<>的函数封装
    shell 判断目录还是文件
    大写金额转小写(千万以下)
    python将有序列表转乱序,模拟音乐播放器随机播放列表
    ssh登录远程linux服务器的错误
    ubuntu Unable to locate package错误解决办法
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/5035779.html
Copyright © 2011-2022 走看看