delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/18/03:00:27

Message-ID: <3497212B.D6CD724B@csun.edu>
Date: Tue, 16 Dec 1997 16:47:39 -0800
From: Ryan Bright <rmb56313 AT csun DOT edu>
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: [Q] Read/Writing 3D-Arr to File
NNTP-Posting-Host: s253n056.csun.edu
Organization: California State University, Northridge
Lines: 42
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I have a simple three-dimensional array of char's, let's say

char arr[3][60][45];

and a file that contains another three-dimensional array of chars but
can contain any amount of data, let's say

char farr[3][500][500]

Note that the first value will always be 3.  Now, the first array is
basically a window to the larger farr.  So, I need to fill arr from a
given [z][y][x] (z = 0) in farr, so that :

+-----------------+
|  +-------+      |
|  |       |      |
|  |arr    |      |
|  +-------+      |
|farr             |
+-----------------+

I didn't draw in the third dimension to avoid confusion.  My first
question would be, how the hell do I do this?  If the file is laid out
the way I think it is would I,

scan to y * 0 + x
read in arr_width values
scan to y * 1 + x
read in arr_width values
...
then scan to the next z value : z * 1 + (y * 0) + x
and repeat
...
etc

This sounds pointlessly complex (Speed is an issue), so I was thinking
that if I set up the file differently, I might be able to read it
faster.  But if I change the setup of the file differently, then I can
really only read and write one character at a time.  Help!

-Ryan
rmb56313 AT csun DOT edu

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019