.raw文件格式C ++ [英] .raw file format C++

查看:97
本文介绍了.raw文件格式C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以使用C ++生成.raw文件格式.如果是,那么哪个班级处理它?如果可能的话,请写下示例代码.

I want to know is it possible to generate .raw file format using C++. If yes then which class deals with it? If possible kindly put down a sample code.

我有(XYZ)< Number> 格式的数据,该数据表示(XYZ)(X + 1 Y +1 Z + 1).我需要使用 ParaView 以图形方式表示此数据,因此需要二进制格式的数据.所以想知道是否可以直接生成.raw文件格式?

I have data of the format (X Y Z) <Number> which represents the number of particles between (X Y Z) and (X+1 Y+1 Z+1). I need to represent this data graphically using ParaView and hence need my data in binary format. So would like to know is it possible to directly generate .raw file format?

推荐答案

通常,要将二进制数据写入C ++文件中,您将需要使用 ofstream :

Generally, to write binary data to a file in C++, you will want to use an ofstream:

#include <fstream.h>
...

{
   MyData myData = GetData();
   ofstream binaryFile ("file.raw", ios::out | ios::binary);
   binaryFile.write ((char*)&myData, sizeof (MyData));
   binaryFile.close();
}

由您决定该应用程序使用的实际格式(如上例中的 Data 结构),然后将其写入文件中.

It is up to you to determine the actual format (like the Data structure in the example above) that this application uses, and then write it to a file.

这篇关于.raw文件格式C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆