Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: One (silly) question about "C"

Author: Heiner Marxen

Date: 11:34:33 02/05/02

Go up one level in this thread


On February 05, 2002 at 08:32:35, Antonio Senatore wrote:

>Hi friends:
>
>I have one array A[n] and another B[n] (both of the same dimension) and I want
>to make A = B without using a loop like
>
>for (i=0; i < n; i++) A[i] = B[i];
>
>My question is if is it possible to do that without using none kind of loops
>(and as I am working in C, I can't work with vectors or to use the lib
>"algorithm")
>
>Thanks in advance
>
>Antonio

Provided that the dimension is a compile time constant, you can wrap the
array into a struct (with just one member, the array), and then do
a struct assignment.

That way you leave it to the compiler to choose a method.  It might well
end up with a call to memcpy(), or with code equivalent to your loop.
Anyway, it is an option.

Cheers,
Heiner



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.