当前位置: 首页 > news >正文

做网站怎么单独写手机页面哪个浏览器看黄页最快夸克浏览器

做网站怎么单独写手机页面,哪个浏览器看黄页最快夸克浏览器,网站运营与网络营销,网站到公安局备案手续目录 一:IO流的继承关系: 二:输入输出功能 1. 基本用法 2. 格式化输入 3.非格式化输入 4. 格式化输出 三:流 1. 字符流 2. 向字符流中写入数据 3. 从字符流中读出数据 4. 清空字符流 5.完整的例子 四:文件…

目录

一:IO流的继承关系:

二:输入输出功能

1. 基本用法 

 2. 格式化输入

3.非格式化输入

4. 格式化输出

三:流

1. 字符流

2. 向字符流中写入数据

3. 从字符流中读出数据

4. 清空字符流

5.完整的例子

四:文件流


一:IO流的继承关系:

含义
basic_streambuf
 
读取或写入数据
ios_base独立于字符类型的流属性
basic_ios依赖于字符类型的流属性
basic_istream用于读取数据的流基类
basic_iostream用于写入数据的流基类
basic_iostream用于读写数据的流基类

二:输入输出功能

typedef basic_istream<char> istream;
typedef basic_ostream<char> ostream;
1. 基本用法 

#include <iostream>
int main(){
std::cout << "Type in your numbers";
std::cout << "(Quit with an arbitrary character): " << std::endl;
// 2000 <Enter> 11 <a>
int sum{0};
int val;
while (std::cin >> val) sum += val;
std::cout << "Sum: " << sum; // Sum: 2011
}
 2. 格式化输入
include <iostream>int main()
{int a, b;std::cout << "Two natural numbers: " << std::endl;std::cin >> a >> b; // < 2000 11>std::cout << "a: " << a << " b: " << b;
}
3.非格式化输入
#include <iostream>int main()
{std::string line;std::cout << "Write a line: " << std::endl;std::getline(std::cin, line); // <Only for testing purpose.>std::cout << line << std::endl; // Only for testing purpose.std::cout << "Write numbers, separated by;" << std::endl;while (std::getline(std::cin, line, ';') ) {std::cout << line << " ";} 
}
4. 格式化输出
#include <iostream>int main()
{int num{2011};std::cout.setf(std::ios::hex, std::ios::basefield);std::cout << num << std::endl; // 7dbstd::cout.setf(std::ios::dec, std::ios::basefield);std::cout << num << std::endl; // 2011std::cout << std::hex << num << std::endl; // 7dbstd::cout << std::dec << num << std::endl; // 2011
}
#include <iostream>
#include <fstream>
#include <iomanip>
#include <iostream>int main()
{std::cout.fill('#');std::cout << -12345;std::cout << std::setw(10) << -12345; // ####-12345std::cout << std::setw(10) << std::left << -12345; // -12345####std::cout << std::setw(10) << std::right << -12345; // ####-12345std::cout << std::setw(10) << std::internal << -12345; //-####12345std::cout << std::oct << 2011; // 3733std::cout << std::hex << 2011; // 7dbstd::cout << std::showbase;std::cout << std::dec << 2011; // 2011std::cout << std::oct << 2011; // 03733std::cout << std::hex << 2011; // 0x7dbstd::cout << 123.456789; // 123.457std::cout << std::fixed;std::cout << std::setprecision(3) << 123.456789; // 123.457std::cout << std::setprecision(6) << 123.456789; // 123.456789std::cout << std::setprecision(9) << 123.456789; // 123.456789000std::cout << std::scientific;std::cout << std::setprecision(3) << 123.456789; // 1.235e+02std::cout << std::setprecision(6) << 123.456789; // 1.234568e+02std::cout << std::setprecision(9) << 123.456789; // 1.234567890e+02std::cout << std::hexfloat;std::cout << std::setprecision(3) << 123.456789; // 0x1.edd3c07ee0b0bp+6std::cout << std::setprecision(6) << 123.456789; // 0x1.edd3c07ee0b0bp+6std::cout << std::setprecision(9) << 123.456789; // 0x1.edd3c07ee0b0bp+6std::cout << std::defaultfloat;std::cout << std::setprecision(3) << 123.456789; // 123std::cout << std::setprecision(6) << 123.456789; // 123.457std::cout << std::setprecision(9) << 123.456789; // 123.456789}

三:流

1. 字符流
//String stream for the input of data of type char and wchar_t.
std::istringstream and std::wistringstream//String stream for the output of data of type char and wchar_t.
std::ostringstream and std::wostringstream//String stream for the input or output of data of type char and wchar_t.
std::stringstream and std::wstringstream
2. 向字符流中写入数据
std::stringstream os;
os << "New String";
os.str("Another new String");
3. 从字符流中读出数据
std::string os;
std::string str;
os >> str;
str= os.str();
4. 清空字符流
std::stringstream os;
os.str("");
5.完整的例子
#include <iostream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <sstream>template <typename T>
T StringTo(const std::string& source) {std::istringstream iss(source);T ret;iss >> ret;return ret;
}template <typename T>
std::string ToString(const T& n) {std::ostringstream tmp;tmp << n;return tmp.str();
}int main()
{std::cout << "5= " << StringTo<int>("5"); // 5std::cout << "5 + 6= " << StringTo<int>("5") + 6; // 11std::cout << ToString(StringTo<int>("5") + 6); // "11"std::cout << "5e10: " << std::fixed << StringTo<double>("5e10"); // 50000000000
}

四:文件流

//File stream for the input of data of type char and wchar_t.
std::ifstream and std::wifstream//File stream for the output of data of type char and wchar_t.
std::ofstream and std::wofstream//File stream for the input and output of data of type char and wchar_t.
std::fstream and std::wfstream//Data buffer of type char and wchar_t.
std::filebuf and std::wfilebuf
#include <fstream>int main()
{std::ifstream in("inFile.txt");std::ofstream out("outFile.txt");out << in.rdbuf();
}
#include <fstream>
#include <iostream>
#include <istream>
#include <string>void writeFile(const std::string name) {std::ofstream outFile(name);if (!outFile) {std::cerr << "Could not open file " << name << std::endl;exit(1);}for (unsigned int i = 0; i < 10; ++i) {outFile << i << " 0123456789" << std::endl;}
}int main()
{std::string random{ "random.txt" };writeFile(random);std::ifstream inFile(random);if (!inFile) {std::cerr << "Could not open file " << random << std::endl;exit(1);}std::string line;std::cout << inFile.rdbuf();// 0 0123456789// 1 0123456789// 9 0123456789std::cout << inFile.tellg() << std::endl; // 200inFile.seekg(0); // inFile.seekg(0, std::ios::beg);std::getline(inFile, line);std::cout << line; // 0 0123456789inFile.seekg(20, std::ios::cur);std::getline(inFile, line);std::cout << line; // 2 0123456789inFile.seekg(-20, std::ios::end);std::getline(inFile, line);std::cout << line; // 9 0123456789
}

五:IO流运算符重载,支持用户自定义类型输入输出

friend std::istream& operator>> (std::istream& in, Fraction& frac);
friend std::ostream& operator<< (std::ostream& out, const Fraction& frac);
#include <fstream>
#include <iostream>
#include <istream>
#include <string>class Fraction {
public:Fraction(int num = 0, int denom = 0) :numerator(num), denominator(denom) {}friend std::istream& operator>> (std::istream& in, Fraction& frac);friend std::ostream& operator<< (std::ostream& out, const Fraction& frac);
private:int numerator;int denominator;
};
std::istream& operator>> (std::istream& in, Fraction& frac) {in >> frac.numerator;in >> frac.denominator;return in;
}
std::ostream& operator<< (std::ostream& out, const Fraction& frac) {out << frac.numerator << "/" << frac.denominator;return out;
}int main()
{Fraction frac(3, 4);std::cout << frac; // 3/4std::cout << "Enter two numbers: ";Fraction fracDef;std::cin >> fracDef; // <1 2>std::cout << fracDef; // 1/2}

http://www.yidumall.com/news/26568.html

相关文章:

  • 中英文网站制作seo技巧分享
  • 做外贸的网站开店流程排行榜123网
  • 网页制作与网站建设宝典seo01网站
  • b2b 网站开发廊坊seo关键词排名
  • 旅游网站开发的意义相关资料谷歌关键词排名查询
  • 理解wordpress轮翻图代码seo是啥
  • 做 cad效果图网站网站排名靠前方法
  • 如何用网站模板建设网站手机自动排名次的软件
  • 做网站测试心得店铺推广怎么做
  • 网站建设和优化要求宁波seo搜索平台推广专业
  • 创办一个网站多少钱做一套二级域名网站怎么做
  • 上海响应式网站建设费用百度地图推广
  • 义乌网站建设zisou8广州seo营销培训
  • 做塑胶原料用什么网站好郑州seo服务公司
  • 博州住房和城乡建设部网站域名查询 ip
  • 域名备案中网站负责人奶茶软文案例300字
  • 云南建设厅网站安全处seo排名优化工具推荐
  • 为女友做网站晋城网站seo
  • 旅游网站开发费用口碑营销案例分析
  • 企业建网站 优帮云佛山全网营销推广
  • 怎么做网络销售的网站淘宝店铺怎么推广和引流
  • 河南郑州网站设计公司营销软件站
  • 典型的网站案例百度云网页版登录入口
  • asp.net mvc网站发布教程百度seo软件
  • 佛山做网站3000百度站长app
  • 如何做旅游网站郑州seo网站排名
  • 求人做网站关键词在线听
  • wordpress 轮廓关键词优化顾问
  • 什么是网站后台建设关系网站优化公司
  • 自建房设计图软件app在线排名优化