C++ 常用函数记录

  • 求平方根:double sqrt(double)
  • x的y次幂:double pow( double x, double y )
  • 求字符串的长度:int strlen(char *s) // 不包含'\0'
  • 字符串比较:int strcmp(const char *s1,const char * s2); // s1>s2,返回一个正数;s1<s2,返回一个负数;s1==s2,返回0
  • 字符串转换为数字: int atoi(const char *nptr); // 参数nptr字符串,如果第一个非空格字符存在,是数字或者正负号则开始做类型转换,之后检测到非数字(包括结束符 \0) 字符时停止转换,返回整型数;否则,返回零。
  • 数字转化为字符串:char *itoa(int value, char *string, int radix); // int value 被转换的整数,char *string 转换后储存的字符数组,int radix 转换进制数,如2,8,10,16 进制等
posted on 2014-02-18 13:48  学习,记录,总结  阅读(292)  评论(0编辑  收藏  举报