Solved

How to write LONGLONG data in a File

Posted on 2003-10-27
5
211 Views
Last Modified: 2013-11-20
I want to write LONGLONG data (which is 64 bit integer) in a file. How can I do so?
0
Comment
Question by:asger_cse
5 Comments
 

Author Comment

by:asger_cse
ID: 9630957
Give a sample code also.
0
 
LVL 8

Accepted Solution

by:
martynjpearson earned 125 total points
ID: 9632270
There are loads of ways - if you want to write to the file as binary (i.e. not a text file) you can do this :

__int64 i64MyInt = 1234;
CFile fileOut("C:\\MyFile.bin", CFile::modeCreate | CFile::modeWrite | CFile::shareDenyWrite);
fileOut.Write((void *)&i64MyInt, sizeof(__int64));
fileOut.Close();

This can then be read in a similar way, passing the address of the __int64 as the buffer, and sizeof(__int64) as the buffer size.

If you want to write it to a text file, you can do this :

__int64 i64MyInt = 1234;

CString strLine;
strLine.Format("%I64d", i64MyInt);

CStdioFile fileOut("C:\\MyFile.txt", CFile::modeCreate | CFile::modeWrite | CFile::shareDenyWrite);
fileOut.WriteString(strLine + "\n");
fileOut.Close();


Hope this helps
Martyn
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now