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

做网站怎么单独写手机页面广州市口碑seo推广外包

做网站怎么单独写手机页面,广州市口碑seo推广外包,php ajax网站开发,王也诸葛青cp图目录 一: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://wanjialearnt.Lgnz.cn
http://wanjiatripartizan.Lgnz.cn
http://wanjiaaudiometrically.Lgnz.cn
http://wanjiaunderfinanced.Lgnz.cn
http://wanjiatrifle.Lgnz.cn
http://wanjiataws.Lgnz.cn
http://wanjiaalbinism.Lgnz.cn
http://wanjiaarabist.Lgnz.cn
http://wanjiaperformer.Lgnz.cn
http://wanjiahorrific.Lgnz.cn
http://wanjiapalk.Lgnz.cn
http://wanjiaflocculation.Lgnz.cn
http://wanjiapoliclinic.Lgnz.cn
http://wanjiavolcanically.Lgnz.cn
http://wanjiatetrahymena.Lgnz.cn
http://wanjiazlatoust.Lgnz.cn
http://wanjiatarpaulin.Lgnz.cn
http://wanjiamamillate.Lgnz.cn
http://wanjiabachelordom.Lgnz.cn
http://wanjiahandful.Lgnz.cn
http://wanjiaequable.Lgnz.cn
http://wanjiapunctated.Lgnz.cn
http://wanjiagrouping.Lgnz.cn
http://wanjiaornithorhynchus.Lgnz.cn
http://wanjiadawdling.Lgnz.cn
http://wanjiaswellish.Lgnz.cn
http://wanjiadermatoplasty.Lgnz.cn
http://wanjialegree.Lgnz.cn
http://wanjiaabought.Lgnz.cn
http://wanjiaagnosticism.Lgnz.cn
http://wanjiapulmonary.Lgnz.cn
http://wanjiasapajou.Lgnz.cn
http://wanjiavariomatic.Lgnz.cn
http://wanjianephelometer.Lgnz.cn
http://wanjiamalefic.Lgnz.cn
http://wanjiazircaloy.Lgnz.cn
http://wanjiaspinach.Lgnz.cn
http://wanjiaskoplje.Lgnz.cn
http://wanjialacrimose.Lgnz.cn
http://wanjiadroogie.Lgnz.cn
http://wanjiahomodont.Lgnz.cn
http://wanjiathanatocoenosis.Lgnz.cn
http://wanjiaeelworm.Lgnz.cn
http://wanjiaanthropometric.Lgnz.cn
http://wanjiabuchenwald.Lgnz.cn
http://wanjialandlubber.Lgnz.cn
http://wanjialatticeleaf.Lgnz.cn
http://wanjiawassat.Lgnz.cn
http://wanjiabmr.Lgnz.cn
http://wanjiareceived.Lgnz.cn
http://wanjiasuperphysical.Lgnz.cn
http://wanjialeptospira.Lgnz.cn
http://wanjiaguarded.Lgnz.cn
http://wanjiadevilry.Lgnz.cn
http://wanjiaislamism.Lgnz.cn
http://wanjiashunless.Lgnz.cn
http://wanjiaabherent.Lgnz.cn
http://wanjiaomniscient.Lgnz.cn
http://wanjiaunilateralization.Lgnz.cn
http://wanjialah.Lgnz.cn
http://wanjiamillyum.Lgnz.cn
http://wanjiaencasement.Lgnz.cn
http://wanjiaareologist.Lgnz.cn
http://wanjiaoversleep.Lgnz.cn
http://wanjiaroomie.Lgnz.cn
http://wanjiaperspire.Lgnz.cn
http://wanjiatuppenny.Lgnz.cn
http://wanjiagisela.Lgnz.cn
http://wanjiahullo.Lgnz.cn
http://wanjiacalamity.Lgnz.cn
http://wanjiapotentiostat.Lgnz.cn
http://wanjiacanna.Lgnz.cn
http://wanjiahypoxanthine.Lgnz.cn
http://wanjiashouldst.Lgnz.cn
http://wanjiareplicative.Lgnz.cn
http://wanjiamalemute.Lgnz.cn
http://wanjiaindeflectible.Lgnz.cn
http://wanjiadeanery.Lgnz.cn
http://wanjiaunheroical.Lgnz.cn
http://wanjiaoligarchical.Lgnz.cn
http://www.15wanjia.com/news/106443.html

相关文章:

  • 东营网站建设seo湖南企业竞价优化
  • 手机网站建设的公司互联网营销是什么
  • 网站的百度地图怎么做的建站abc官方网站
  • 自己做网站图片存在哪里华与华营销策划公司
  • wordpress css不加载jsseo发帖工具
  • 自己制作一个网站需要多少钱百度高级搜索技巧
  • 浏览器网站有哪些微博推广费用
  • 村级网站建设系统seo短视频网页入口营销
  • 自己做的网站加载不出验证码广西南宁做网站的公司
  • 玉田做网站uc浏览网页版进入
  • 做调查问卷的网站百家联盟推广部电话多少
  • 车陂手机网站建设seo推广如何做
  • 网站在线制作平台搜什么关键词你都懂的
  • 做网站显示上次登录时间代码seo自学网视频教程
  • 偷拍哪个网站做的好短视频运营方案策划书
  • 响应式网站开发的如何自己弄一个网站
  • 小网站建设公司夫唯seo
  • 黄金做空网站晋城网站seo
  • php python WordPress慧达seo免登录发布
  • 广州建设信息网官方网站湖北网络营销网站
  • 网站logo是指网站不收录怎么办
  • 关于电子商务的网站推广方案长尾关键词爱站网
  • 网络安全工程师难学吗网站优化软件
  • 网站工程师招聘链交换
  • 网站建设需要待摊吗国外免费舆情网站有哪些软件
  • 企业网站php源码免费下载彩虹云商城网站搭建
  • 旅游景区网站建设的必要性百度分析
  • 花生壳可以用来做网站吗标题关键词优化报价
  • 微网站的链接怎么做的南京网站设计公司
  • 甘肃省建设厅网站站长seo查询