首页 > 其他分享 >流类库7

流类库7

时间:2023-05-15 11:46:56浏览次数:22  
标签:类库 int ios base values sizeof os

#include<iostream>
#include<fstream>
using namespace std;
int main()
{
int values[]={3,7,0,5,4};
ofstream os("integers",ios_base::out | ios_base::binary);
os.write(reinterpret_cast<char *>(values),sizeof(values));
os.close();
ifstream is("integers",ios_base::Init | ios_base::binary);
if(is){
is.seekg(3*sizeof(int));
int v;
is.read(reinterpret_cast<char *>(&v),sizeof(int));
cout<<"The 4th integer in the file 'integers' is "<<v<<endl;
}else{
cout<<"ERROR:Cannot open file 'integers'."<<endl;
}
return 0;
}

标签:类库,int,ios,base,values,sizeof,os
From: https://www.cnblogs.com/yuanxinglan/p/17401379.html

相关文章

  • 流类库6
    #include<iostream>#include<fstream>#include<cstring>usingnamespacestd;structSalaryInfo{ unsignedid; doublesalary;};intmain(){ SalaryInfoemployee1={600001,8000}; ofstreamos("payroll",ios_base::out|ios_base::binary); os......
  • 流类库4
    #include<iostream>#include<iomanip>#include<string>usingnamespacestd;template<classT>inlinestringtoString(constT&v){ ostringstreamos; os<<v; returnos.str();}intmain(){ stringstr1=toString(5); cout<<str1&l......
  • 流类库3
    #include<iostream>#include<iomanip>#include<string>usingnamespacestd;intmain(){ doublevalues[]={1.23,35.36,653.7,4358.24}; stringnames[]={"Zoot","Jimmy","Al","Stan"}; for(inti=0;i<4;i++) c......
  • 流类库2
    #include<iostream>#include<iomanip>#include<string>usingnamespacestd;intmain(){ doublevalues[]={1.23,35.36,653.7,4358.24}; stringnames[]={"Zoot","Jimmy","Al","Stan"}; for(inti=0;i<4;i++) c......
  • java:常用工具类库
    最近一直在减少造轮子的做法,简单总结了一下各个工具类库:排名不分先后,链接的地址为自己找了几个比较合适的例子,供参考。 1、ApacheCommonApacheCommons是对JDK的拓展,包含了很多开源的工具,用于解决经常会遇到的问题,减少重复工作。 2、GoogleGuava Guava工程包含了若干......
  • C# 如何将类库项目转换为Web应用程序项目?
    1)在靠近顶部的元素之后添加<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>2)删除Local3)在文件的底部,在关闭之前,添加<ImportProject="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0\Web......
  • WPF 给类库设置设计时使用的资源字典
    在开发多语言版本时,我将界面显示的文本保存在语言资源zh.xaml和en.xaml中,但程序启动,加载语言资源时是外部的配置文件决定的,因此语言资源我无法添加在App.xaml文件中,而开发单个XAML界面时,设计器将会因为找不到资源文件的存在,而拿不到资源,每次遇到语言相关的资源键值,都需要手动去......
  • C# 常用开发类库整理
    1、CalcHelper——利用MSScriptControl组件实现公式计算2、CookieExpressionHelper——读取/设置Cookie数据,是对CookieHelper的扩展,参数使用表达式,目的是减少属性名的拼写错误。3、CookieHelper——读取/设置Cookie数据。4、CopyHelper——实体属性值之前相互拷贝......
  • 类库项目无法引用Microsoft.AspNetCore程序集下的类库
    在类库项目中不能直接引用WebApplicationBuilder、ApplicationBuilder等类,这些类位于Microsoft.ASPNetCore程序集中,但是无法通过Nuget包引用,因为该Nuget包的版本已经不再支持,很久没有更新过了。解决方法:在项目文件csproj文件中,在ItemGroup下手动添加引用<FrameworkReferenceInc......
  • 干掉复杂的工具类,国产Java工具类库 Hutool 很香!
    Hutool大家已经比较熟悉了,这是一个超全的Java工具库,深受国内开发者的喜爱。我之前其实是不太喜欢使用这种功能太多的工具类的,也比较担心稳定性和安全性,后面慢慢接受了就感觉其实也还好。而且,我们还可以按需只引入自己需要的功能模块,相对也比较灵活。Hutool的官方文档介绍的......