c++ 64 bit inpout

Posted on 2005-03-29
Medium Priority
Last Modified: 2010-04-01
how can I read from input file as 64 bit blocks?
Question by:saif20
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

Expert Comment

ID: 13650651
what is the format of your input file?

simple fread can do it.

some thing like this...
typedef unsigned char byte;

byte data[8];
fread(fp, data, sizeof(data));


Author Comment

ID: 13650713

thank I 'll give i tray.
my data format is normal text (char) file.
I need to read it in blocks 64 bits split it into two parts and then run ECB encryption in it.
LVL 55

Expert Comment

by:Jaime Olivares
ID: 13651671
if you are working with Windows environment, you can use __int64 data type or maybe ULARGE_INTEGER, so you can have all data in just one fundamental variable.

Author Comment

ID: 13652279
I am using unix sun solray g++
LVL 86

Accepted Solution

jkr earned 1500 total points
ID: 13652453
Solaris should also have "ISO C99: 7.18 Integer types <stdint.h>". So, you could use

union 64bit_buf {

    char plain[8];
    int64_t i64;

Then, you can read the text as

FILE* p = fopen("infile","r");
64bit_buf buf;

while (!feof(p)) {




Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

777 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