regarding multidimensional arrays

S

santosh

ume said:
how can iconvert the 4 dimensional array to single dimensionla array?
example
m[2][6][4][4] is the four dimensional array
m[] into 1 dimension

Well, one possibility is to copy the elements of the four dimensional
array to a single dimensional array. A nested for loop construct can
be used for this.
 
F

Flash Gordon

ume wrote, On 05/03/07 09:50:
how can iconvert the 4 dimensional array to single dimensionla array?
example
m[2][6][4][4] is the four dimensional array
m[] into 1 dimension

It depends on what you want to do. If you just want to access it as if
it was 1D you can do

{
int m[2][6][4][4];
int *p = (int*)m;
/* whatever using p[x] */
}
 
U

ume

ume wrote, On 05/03/07 09:50:
how can iconvert the 4 dimensional array to single dimensionla array?
example
m[2][6][4][4] is the four dimensional array
m[] into 1 dimension

It depends on what you want to do. If you just want to access it as if
it was 1D you can do

{
int m[2][6][4][4];
int *p = (int*)m;
/* whatever using p[x] */}
for ex this is my multi array how can i ...
for (l=0; l < 2; l++)
for (j=0; j < 4; j++)
for (i=0; i < 5; i++)
for (k=0; k < 3; k++)
m[l][j][k] = 0;


write it in single dimension with/without using pointers
 
S

santosh

ume said:
ume wrote, On 05/03/07 09:50:
how can iconvert the 4 dimensional array to single dimensionla array?
example
m[2][6][4][4] is the four dimensional array
m[] into 1 dimension

It depends on what you want to do. If you just want to access it as if
it was 1D you can do

{
int m[2][6][4][4];
int *p = (int*)m;
/* whatever using p[x] */}

for ex this is my multi array how can i ...
for (l=0; l < 2; l++)
for (j=0; j < 4; j++)
for (i=0; i < 5; i++)
for (k=0; k < 3; k++)
m[l][j][k] = 0;


write it in single dimension with/without using pointers


You cannot use an array in C without using a pointer.
 
F

Flash Gordon

CBFalconer wrote, On 06/03/07 10:14:
Flash Gordon wrote:
... snip all ...

You and Santosh seem to have clock problems. Both messages were
sent in the future.

You you sure you aren't living in the past? My clock looks OK to me.
Admittedly it's on GMT and I'm not in the UK at the moment, but the time
in the post time stamp said +0:00 so that should be OK.
 
R

Richard Heathfield

CBFalconer said:
... snip all ...

You and Santosh seem to have clock problems. Both messages were
sent in the future.

Chuck - I wasn't going to mention this, but since you raise the subject,
your own articles frequently appear very, very much in the past. That
may just be because my server picks them up several hours later than it
picks up most people's, or it may be a problem with your settings.
 
C

CBFalconer

Flash said:
CBFalconer wrote, On 06/03/07 10:14:


You you sure you aren't living in the past? My clock looks OK to me.
Admittedly it's on GMT and I'm not in the UK at the moment, but the
time in the post time stamp said +0:00 so that should be OK.

If you examine the date stamps, yours was sent at 11:03 GMT,
Santoshs at 10:43 GMT, and my reply was at 10:42 GMT. At least one
of us is wrong, or there has been an important scientific
breakthrough. All my clocks seem to agree within one minute.
Santosh may be a minor clock error and a rapid article propagation.

Woops - rechecking there is a 24 hour factor. I take it all back.
That also means there was a nearly 24 hour delay in propagation to
me!

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
 
C

CBFalconer

Richard said:
CBFalconer said:

Chuck - I wasn't going to mention this, but since you raise the
subject, your own articles frequently appear very, very much in
the past. That may just be because my server picks them up several
hours later than it picks up most people's, or it may be a problem
with your settings.

That's because I operate off-line. The time is when I hit 'send'.
The actual transmission doesn't take place until I get around to
going back on line, which may be some time later. That may be
after finishing looking at c.l.c and up to 19 more newsgroups.
This also gives me some time to rue venting my phlegm and delete
(or mitigate) my response.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
 
J

Joe Wright

Richard said:
CBFalconer said:


Chuck - I wasn't going to mention this, but since you raise the subject,
your own articles frequently appear very, very much in the past. That
may just be because my server picks them up several hours later than it
picks up most people's, or it may be a problem with your settings.
Chuck is behind the times? Seriously though, how is Usenet time supposed
to be displayed? This system I'm on now is Windows XP with its time set
to US Eastern time (GMT -5:00) or somesuch. It is about 18:00 EST as I
post this (I'll try to post the exact indicated time as I press the Send
key).

Question: In a given thread I find several posts from all over the
world, each with an indicated date and time. Whose time is it? Should my
newsreader know that local time for Heathfield is GMT+1 (is it?) and
report his post to me in EST (GMT-5)?

Current date_time is 2007-03-06 18:15
 
R

Richard Heathfield

Joe Wright said:

Seriously though, how is Usenet time
supposed to be displayed? This system I'm on now is Windows XP with
its time set to US Eastern time (GMT -5:00) or somesuch. It is about
18:00 EST as I post this (I'll try to post the exact indicated time as
I press the Send key).

A good client will convert the time of the article into local time. You
sent your article at 18:15 your time, and I received it at about 23:23
my time, with a stamp of 23:15 (i.e. the time of posting was converted
into my local time).
Question: In a given thread I find several posts from all over the
world, each with an indicated date and time. Whose time is it? Should
my newsreader know that local time for Heathfield is GMT+1 (is it?)

It's actually GMT*, which your newsreader should indeed know.
and report his post to me in EST (GMT-5)?

Yes.

* For the convenience of Usenetters around the world and also, it must
be admitted, out of sheer cussedness, I have this machine set to GMT
all year round. "Daylight savings"? Bah! Humbug!
 
C

CBFalconer

Joe said:
.... snip ...

Question: In a given thread I find several posts from all over the
world, each with an indicated date and time. Whose time is it?
Should my newsreader know that local time for Heathfield is GMT+1
(is it?) and report his post to me in EST (GMT-5)?

Current date_time is 2007-03-06 18:15

The display format is up to your newsreader. The raw message
source should have date headers which include their relationship to
GMT. You are apparently located in a Central Time zone.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
 
J

Joe Wright

Richard said:
Joe Wright said:



A good client will convert the time of the article into local time. You
sent your article at 18:15 your time, and I received it at about 23:23
my time, with a stamp of 23:15 (i.e. the time of posting was converted
into my local time).


It's actually GMT*, which your newsreader should indeed know.


Yes.

* For the convenience of Usenetters around the world and also, it must
be admitted, out of sheer cussedness, I have this machine set to GMT
all year round. "Daylight savings"? Bah! Humbug!
This post is reported to me at 18:29. Thanks for responding. This is
definitely UB of course. The Standard doesn't know what time it is. :)

Now it's 21:32
 
K

Keith Thompson

Joe Wright said:
This post is reported to me at 18:29. Thanks for responding. This is
definitely UB of course. The Standard doesn't know what time it is. :)

It may know what time() it is, though.
 
F

Flash Gordon

CBFalconer wrote, On 06/03/07 19:04:
If you examine the date stamps, yours was sent at 11:03 GMT,

Woops - rechecking there is a 24 hour factor. I take it all back.
That also means there was a nearly 24 hour delay in propagation to
me!

Well, we do keep telling people it can take a while for messages to get
through (if they ever do) ;-)
 
P

Peter Nilsson

ume said:
how can iconvert the 4 dimensional array to single dimensionla
array? example
m[2][6][4][4] is the four dimensional array

m[] into 1 dimension

#define countof(x) ((size_t)(sizeof(x)/sizeof*(x)))
T m[2][6][4][4];
T n[countof(m) * countof(*m) * countof(**m) * countof(***m)];
memcpy(n, m, sizeof m);

Note that you can also declare n as...

T n[sizeof m / sizeof ****m];
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,191
Latest member
BuyKetoBeez

Latest Threads

Top