zoukankan      html  css  js  c++  java
  • 几种常见的库函数

    string s = to_string(num);/*
              std::string to_string(int value); (1) (C++11起)
              std::string to_string(long value); (2) (C++11起)
              std::string to_string(long long value); (3) (C++11起)
              std::string to_string(unsigned value); (4) (C++11起)
              std::string to_string(unsigned long value); (5) (C++11起)
              std::string to_string(unsigned long long value); (6) (C++11起)
              std::string to_string(float value); (7) (C++11起)
              std::string to_string(double value); (8) (C++11起)
              std::string to_string(long double value); (9) (C++11起)
              */      

    今天使用substring()函数,对于参数理解不是很好,在网上看也有好多错的,自己测试了一遍,记录下来

    substring(int beginIndex,int endIndex)中第一个参数是开始位置,第二个参数是结束位置,

    String s="abcdefg";
    System.out.println(s.substring(2,4));

    结果:cd

    如果只给一个参数,是从参数位置开始,一直到结束

    String s="abcdefg";
    System.out.println(s.substring(2));

    结果:cdefg

    注意:下标从零开始,包括前面的,不包括后面的,也可以看成是下标从一开始,不包括开始,包括结束。

    /*******

    vs环境下:
    stoi函数默认要求输入的参数字符串是符合int范围的[-2147483648, 2147483647],否则会runtime error。
    atoi函数则不做范围检查,若超过int范围,则显示-2147483648(溢出下界)或者2147483647(溢出上界)。
    
    
    stoi头文件:<string>,c++函数
    atoi头文件:<cstdlib>,c函数
    *******/
  • 相关阅读:
    Python YAML
    Python JASON
    Python正则表达式
    := / ?= /+=
    eclipse的springMVC环境搭建并输出HelloWorld
    SpringMVC简单介绍
    一个简单的MyBatis项目(应用)
    No mapping found for HTTP request with URI [/spring_liu/hello.do] in DispatcherServlet with name 'SpringMVC'
    xml中单词下面有提示下划线
    为什么maven 创建web工程不自动生成Deployment Descriptor:工程名
  • 原文地址:https://www.cnblogs.com/binanry/p/9623000.html
Copyright © 2011-2022 走看看