delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/30/08:34:54

From: Chris Mears <cmears AT bigpond DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Array swapping.
Organization: only if absoultely necessary
Message-ID: <giaogscm124q67h7ksso8o3sihu3jl29n3@4ax.com>
References: <390B75BB DOT 621F846A AT gtcom DOT net> <be7ngssbe6fnhur5if8j27a3ct35gpj2e9 AT 4ax DOT com>
X-Newsreader: Forte Agent 1.8/32.548
MIME-Version: 1.0
Lines: 48
Date: Sun, 30 Apr 2000 22:43:42 +1000
NNTP-Posting-Host: 139.134.82.95
X-Trace: newsfeeds.bigpond.com 957098205 139.134.82.95 (Sun, 30 Apr 2000 22:36:45 EST)
NNTP-Posting-Date: Sun, 30 Apr 2000 22:36:45 EST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Sun, 30 Apr 2000 12:45:54 +1000, that hoopy frood Chris Mears
<cmears AT bigpond DOT com> wrote:

>On Sat, 29 Apr 2000 19:52:27 -0400, that hoopy frood Krogg
><krogg DOT no DOT to DOT spam AT gtcom DOT net> wrote:
>
>>
>>I got 2 arrays of same type/size.
>>
>>float abc[50][50];
>>float cba[50][50];
>>
>>how can i "swap" them?
>>
>>so that abc[x][y] will now point to cba[x][y] and
>>vice versa...
>>
>>I dont care if it is portable,just so long as
>>it works and can be done over and over.....
>
>Uncompiled, untested.
>
>void swap(float a[50][50], float b[50][50])
>{
>    int i;
>    int j;
>
>    for (i = 0 ; i < 50 ; i++)
>    {
>        for (j = 0 ; j < 50 ; j++)
>        {
>            float temp = a[i][j];
>            a[i][j] = b[i][j];
>            b[i][j] = a[i][j];

Ahhh yes, I *was* asleep at the wheel.  Thanks Martin.

(Should be "b[i][j] = temp;")

>        }
>    }
>}


-- 
Chris Mears

ICQ: 36697123

- Raw text -


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