• cpp常用函数总结


    //sprintf
    
    sprintf(temp_str_result, "%lf", temp_double); 
    
    result = temp_str_result;
    
    (*begin) = result;
    
    
    
    int main( void )
    
    {
    
        const double value = 12.3456789;
    
    
        cout << value << endl; // 默认以6精度,所以输出为 12.3457
    
        cout << setprecision(4) << value << endl; // 改成4精度,所以输出为12.35
    
        cout << setprecision(8) << value << endl; // 改成8精度,所以输出为12.345679
    
        cout << fixed << setprecision(4) << value << endl; // 加了fixed意味着是固定点方式显示,所以这里的精度指的是小数位,输出为12.3457
    
        cout << value << endl; // fixed和setprecision的作用还在,依然显示12.3457
    
        cout.unsetf( ios::fixed ); // 去掉了fixed,所以精度恢复成整个数值的有效位数,显示为12.35
    
        cout << value << endl;
    
        cout.precision( 6 ); // 恢复成原来的样子,输出为12.3457
    
        cout << value << endl;
    
    }
    
    

    define PI 3.14159265358979

    double PI=atan(1.0)*4;

    binary 二进制的

    octal 八进制的

    hexadecimal 十六进制的

    decimal 十进制的

    include

    String str;

    Const char * c = str.c_str();

    int a = itoa(s[]) ;

    itoa(890,s[],10);

    第一个参数是int 第二个参数是字符串 第三个是进制

    void *memset(void *s, int ch, size_t n);

    函数解释:将s中前n个字节 (typedef unsigned int size_t )用 ch 替换并返回 s 。

    memset:作用是在一段内存块中填充某个给定的值,它是对较大的结构体或数组进行清零操作的一种最快方法。

    一定要记住如果要把一个char a[20]清零,一定是 memset(a,0,20*sizeof(char));

    //读取整行

    
    char str[100];  
    
    while(gets(str)!=NULL)
    
    {  
    
     cout<<"***"<<str<<"---"<<endl;  
    
    }
    
    
    gets(s[]);
    
    
    string str;
    
    getline(cin,str,'#');
    
    cout << str;
    

    vector的find函数 find(vec.begin(),vec.end(),需要查询的数字)==vec.end()

    __64int a --> long long a printf("%I64d",a);

  • 相关阅读:
    JTS相关资料和示例
    微信、支付宝支付那点事
    系统化全方位监控告警,这一篇足矣
    耶鲁大学研究创造了模拟人类认知的计算机芯片
    Docker孵化的5个开源项目
    图解数据中心水系统标准和架构(大全)
    React Native 项目整合 CodePush 全然指南
    1分钟了解MyISAM与InnoDB的索引差异
    Google I/O 官方应用中的动效设计
    为了完毕月入三万的目标,我都做了哪些准备?
  • 原文地址:https://www.cnblogs.com/maskerk/p/7348842.html
Copyright © 2020-2023  润新知