Solved

How to write LONGLONG data in a File

Posted on 2003-10-27
5
245 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

685 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