随笔分类 -  C++

c++中的string用法(二)
摘要:转载自:http://www.programfan.com/blog/article.asp?id=16881basic_string::compare如果所比较的两个string 相等,则返回0; 操作string 大于参数string,返回正数;操作string 小于参数string,返回负数。(1)比较操作string 与_Str 或C-string_Ptrint compare( const basic_string& _Str ) const;int compare( const value_type* _Ptr ) const;int com = s.compare ( s 阅读全文

posted @ 2013-01-07 22:29 AllenZhao 阅读(327) 评论(0) 推荐(0)

ofstream和ifstream详细用法
摘要:没找到源出处:ofstream是从内存到硬盘,ifstream是从硬盘到内存,其实所谓的流缓冲就是内存空间;在C++中,有一个stream这个类,所有的I/O都以这个“流”类为基础的,包括我们要认识的文件I/O,stream这个类有两个重要的运算符:1、插入器(>) 从流中输入数据。比如说系统有一个默认的标准输入流(cin),一般情况下就是指的键盘,所以,cin>>x;就表示从标准输入流中读取一个指定类型(即变量x的类型)的数据。 在C++中,对文件的操作是通过stream的子类fstream(file stream)来实现的,所以,要用这种方式操作文件,就必须加入头文件fs 阅读全文

posted @ 2013-01-07 22:12 AllenZhao 阅读(341) 评论(0) 推荐(0)

对C++中string类型的总结
摘要:转自:http://www.cnblogs.com/jerrychoi/archive/2009/07/08/1518919.html 1: explicit basic_string();2: string(const char *s);3: string(const char *s, size_type n);4: string(const string& str);5: string(const string& str, size_type pos, size_type n);6: string(size_type n, E c);7: string(const_iter 阅读全文

posted @ 2013-01-07 22:10 AllenZhao 阅读(262) 评论(0) 推荐(0)

导航