Solved

How to write LONGLONG data in a File

Posted on 2003-10-27
5
255 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 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