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;
    }
    
    一个指向数组确实无法使用   瞎蒙 实际测试的~

  • 相关阅读:
    RSA加密及加签
    间隔Ns请求某函数并且有timeout
    关于Erlang中的behaviour
    Erlang&RabbitMQ服务安装配置
    java IO流详解
    Uncaught TypeError: Cannot read property 'options' of undefined
    sql server 数据修改不了的设计
    Android多点触控详解
    java实现图的遍历(深度优先遍历和广度优先遍历)
    判断输入的8个数字不是符合8X8皇后棋盘
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/5035779.html
Copyright © 2011-2022 走看看