
c++
代码修行者
这个作者很懒,什么都没留下…
展开
-
跳入c++1
在c语言中,一定会遇到'\o'的问题,字符串的最后有一个\0 strlen +1 = sizeof c++中也是如此 但是当把字符串赋给变量是就不同了,c语言中只能赋给字符串数组(指针不算),sizeof 永远是一,这个在c++中也一样 在c++中引入了类的概念,可以使用string类 (注:string类 需要 #include原创 2013-08-06 01:04:32 · 740 阅读 · 0 评论 -
跳入c++3 I/O流处理符
#include int main() { std::cout<<"oct ==0"<<std::oct<<1000<<std::endl <<"hex == 0x"<<std::hex<<1000<<std::endl <<"dec == "<<std::dec<<1000<<std::endl; } std::oct hex dec原创 2013-08-10 15:02:45 · 765 阅读 · 0 评论 -
跳入c++2 cin.sync cin.good cin.clear
#include int n; int main() { while(1) { std::cin>>n; if(std::cin.good())//如果输入的是int类型,判断正确 { std::cout<<n<<std::endl; } else {原创 2013-08-07 22:11:10 · 1299 阅读 · 0 评论 -
跳入c++ 4 sprintf
#include #include int main() { char *buffer; sprintf(buffer,"%c,%d",65,65); std::cout<<buffer<<std::endl; return 0; }原创 2013-09-02 14:06:32 · 701 阅读 · 0 评论 -
跳入c++ 5 memmove 字符串截取
#include #include //include memmove int main() { char buffer[10]="12345";//必须声明缓冲区大小,不能char * buffer memmove(&buffer[3],&buffer[2],3); //移动3个字符,因为字符串最后的\0 buffer[3]='.'; std::cout<<buf原创 2013-09-02 14:10:26 · 848 阅读 · 0 评论