?
Solved

c++ 64 bit inpout

Posted on 2005-03-29
5
Medium Priority
?
236 Views
Last Modified: 2010-04-01
how can I read from input file as 64 bit blocks?
0
Comment
Question by:saif20
5 Comments
 
LVL 8

Expert Comment

by:novitiate
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));

_novi_
0
 

Author Comment

by:saif20
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.
 
0
 
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.
0
 

Author Comment

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

Accepted Solution

by:
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)) {

    fread(buf.plain,sizeof(int64_t),1,p);

    do_some_encryprion(&buf.64bit);

}
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

621 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