当前位置:网站首页>Vérification simple de la lecture et de l'écriture de qdatastream
Vérification simple de la lecture et de l'écriture de qdatastream
2022-07-01 05:06:00 【Otek Glodon.】
Le but est d'écrire des binaires et de lire du contenu:
#include <QApplication>
#include <QFile>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QFile aFile1("file.dat");
if (!(aFile1.open(QIODevice::WriteOnly)))//Ouvrir le fichier en écriture seulement
return -1;
QDataStream bStream(&aFile1);
bStream.setVersion(QDataStream::Qt_5_9);
//Écrire à tour de rôle la taille totale de l'espace d'information,Nom du fichier taille de l'espace d'information,Nom du fichier
QString currentFileName = "abcdFile" ;
qint64 v1 = 0,v2 = 0;
bStream << qint64(v1) << qint64(v2) << currentFileName;
//Le curseur retourne au début du fichierqint64Modifier
bStream.device()->seek(0);
v1 = 13548,v2 = 8;
bStream<< qint64(v1) << qint64(v2);
// Cette étape consiste à rafraîchir le fichier , Pour que les documents écrits prennent effet
aFile1.flush();
aFile1.close();
// LiredatDocumentation
QFile aFile2("file.dat");
if (!(aFile2.open(QIODevice::ReadOnly)))//Ouvrir le fichier en écriture seulement
return -1;
QDataStream aStream(&aFile2);
aStream.setVersion(QDataStream::Qt_5_9);
qint64 v3 = 0,v4 = 0;
aStream >> v3 >> v4 >> currentFileName;//Lire les données,DépôttemEtstr
qDebug() << v3 << v4 << currentFileName ;// Imprimer pour voir les résultats
aFile2.close();
return a.exec();
}
边栏推荐
- Global and Chinese market for instant messaging security and compliance solutions 2022-2028: Research Report on technology, participants, trends, market size and share
- Use and modification of prior network model
- RuntimeError: “max_pool2d“ not implemented for ‘Long‘
- FileInputStream
- 【暑期每日一题】洛谷 P2637 第一次,第二次,成交!
- LeetCode522-最长特殊序列II-哈希表-字符串-双指针
- Distributed architecture system splitting principles, requirements and microservice splitting steps
- LeetCode_ 58 (length of last word)
- Overview of the construction details of Meizhou veterinary laboratory
- [daily question in summer] first time, second time, deal!
猜你喜欢

Use and modification of prior network model

Pytoch (III) -- function optimization

智慧运维:基于 BIM 技术的可视化管理系统

Pytoch (II) -- activation function, loss function and its gradient
![解决:Thread 1:[<*>setValue:forUndefinedKey]:this class is not key value coding-compliant for the key *](/img/88/0b99d1db2cdc70ab72d2b3c623dfaa.jpg)
解决:Thread 1:[<*>setValue:forUndefinedKey]:this class is not key value coding-compliant for the key *

How to traverse massive data in redis

Neural networks - use of maximum pooling

Distributed transactions - Solutions

液压滑环的特点讲解

无器械健身
随机推荐
Sqlplus connects using the instance name
JS random verification code
STM32扩展板 数码管显示
如何选择导电滑环材料
【FTP】FTP连接时出现“227 Entering Passive Mode”的解决方法
Youqitong [vip] v3.7.2022.0106 official January 22 Edition
Leetcode316- remove duplicate letters - stack - greedy - string
洗个冷水澡吧
Pytoch (IV) -- visual tool visdom
Global and Chinese markets for business weather forecasting 2022-2028: Research Report on technology, participants, trends, market size and share
Pico Neo3手柄抓取物体
[daily question in summer] Luogu p5740 [deep foundation 7. Example 9] the best student
打印流与System.setout();
科研狗可能需要的一些工具
js解决浮点数相乘精度丢失问题
Principle, technology and implementation scheme of data consistency in distributed database
AcWing 886. Finding combinatorial number II (pretreatment factorial)
导电滑环短路的原因以及应对措施
分布式事务-解决方案
FileInputStream