如何在32位程序中将__int64写入文件? [英] How to write __int64 to file in 32 bit program ?

查看:199
本文介绍了如何在32位程序中将__int64写入文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用QuerryPerformanceCounter来衡量应用程序的性能.它使用__int64作为out参数.我需要将其写入文件中.怎么做. ??

Hi,

I am using QuerryPerformanceCounter to measure performance of the Application. It takes __int64 as a out parameter. I need to write it in the file. How to do it. ??

推荐答案

LARGE_INTEGER performanceCount;
if (QueryPerformanceCounter(&performanceCount))
{
    fwrite(&performanceCount, sizeof performanceCount, 1, fileStream);
}


或类似.


or similar.



FILE *fptr = NULL;
 if(fopen_s(&fptr,"Sample.txt","w") != 0){
     cout << "Could not open file";
 }
 __int64 a=10;
     QueryPerformanceCounter((LARGE_INTEGER*)&a);
 char    b[255];
 sprintf_s(b,255,"%d",a);
 fprintf_s(fptr,"%s",b);
 fclose(fptr);



上面的代码将__int64写入文件,您在编写__int64时遇到任何问题吗?这是QueryPerformanceCounter返回的吗?



The code above writes the __int64 to a file,are you facing any issues in writing __int64 which is returned by QueryPerformanceCounter?


这篇关于如何在32位程序中将__int64写入文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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