Solved

How to write LONGLONG data in a File

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 131
How to determine file rename from EventLog ? 2 55
notReplace  challenge 53 142
countEvens challenge 2 111
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.

860 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