Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"Because of this forum, I continue to WOW! my clients!"

Geography

Where in the world do Tek-Tips members come from?

WRITING THEN READING MULTIDIMENSIAL ARRAY

blackened789 (Programmer)
15 Oct 11 10:06
HOW DO YOU WRITE IN A .BIN FILE AN ARRAY WITH THE FOLLOWING SPECS:

double A[12[17];

THEN HOW DO YOU READ THE FILE SO YOU ARE ABLE TO GET BACK THE DATA?
blackened789 (Programmer)
15 Oct 11 10:19
MAKE IT 2 ARRAYS:

double A[12][17];
int B[40];
 
ArkM (IS/IT--Management)
17 Oct 11 7:47
What's a problem?

CODE

    double a[12][17];
    int     b[40];
    ... // populate a, b...
    const char* fname = "xxxx.xxx";
    std::ofstream fout(fname,std::ios::binary);
    fout.write((const char*)a,sizeof a);
    fout.write((const char*)b,sizeof b);
    fout.close();
then

CODE

    ...
    std::ifstream fin(fname,std::ios::binary);   
    fin.read((char*)a,sizeof a);
    fin.read((char*)b,sizeof b);
    fin.close();
or (non-stop)

CODE

    std::fstream f(fname,std::ios::binary);
    f.write((const char*)a,sizeof a);
    f.write((const char*)b,sizeof b);
    ...
    f.seekg(0); // rewind op
    f.read((char*)a,sizeof a);
    f.read((char*)b,sizeof b);
    ...
    f.close();
Add error checking and go on!..
 

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close