From: Richard Heathfield on
Fabiano said:

>
>
> inquisitive(a)mailinator.com ha scritto:
>
>> int main()
>> {
>> Deck myDeck;
>> memset(&myDeck,0,sizeof(Deck));
>> LoadDeck(&myDeck);
>> PrintDeck(&myDeck);
>> return 0;
>> }
> I suppose...
> myDeck is an array, "myDeck" is a pointer yet to the array.
>
> try
>> memset(myDeck,0,sizeof(Deck));

or just: Deck myDeck = {0};

>> LoadDeck(myDeck);
>> PrintDeck(myDeck);
>
> Am I right?

No.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
From: Fabiano on

Richard Heathfield ha scritto:
> Fabiano said:
>
....
>> I suppose...
>> myDeck is an array, "myDeck" is a pointer yet to the array.
>>
>> try
>>> memset(myDeck,0,sizeof(Deck));
>
> or just: Deck myDeck = {0};

I have understood Deck is an array of Card's elements.(52 cards elements).
Does "Deck myDeck = {0};" suffice in order to initialize it to zero?

>
>>> LoadDeck(myDeck);
>>> PrintDeck(myDeck);
>> Am I right?
>
> No.
>

I'm just trying to learn.What is wrong exactly in my suggestion?thanks
From: Fabiano on
Richard Heathfield ha scritto:
> Fabiano said:
>
>>> memset(myDeck,0,sizeof(Deck));
>
> or just: Deck myDeck = {0};

Oh yes, I have gone deeper and found out an useful example:

float p2[1000] = {0.0}; // All 1000 values initialized to zero.

What a practival way for initialization!
Thanks a lot.

The second question is still valid ;-)
From: Bart van Ingen Schenau on
Fabiano wrote:

>
> Richard Heathfield ha scritto:
>> Fabiano said:
>>
>>>> LoadDeck(myDeck);
>>>> PrintDeck(myDeck);
>>> Am I right?
>>
>> No.
>>
>
> I'm just trying to learn.What is wrong exactly in my suggestion?thanks

What is wrong is that LoadDeck and PrintDeck both expect to receive a
pointer to an array, whereas you try to pass the array itself (which
gets converted to a pointer to the first element).
Those two are different types, so the compiler would not accept your
function calls.

Bart v Ingen Schenau
--
a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq
c.l.c FAQ: http://c-faq.com/
c.l.c++ FAQ: http://www.parashift.com/c++-faq-lite/
From: Fabiano on


Bart van Ingen Schenau ha scritto:
> Fabiano wrote:
>

>> I'm just trying to learn.What is wrong exactly in my suggestion?thanks
>
> What is wrong is that LoadDeck and PrintDeck both expect to receive a
> pointer to an array, whereas you try to pass the array itself (which
> gets converted to a pointer to the first element).
> Those two are different types, so the compiler would not accept your
> function calls.
>
> Bart v Ingen Schenau

Thanks a lot.I have fully understood my error now.
First  |  Prev  | 
Pages: 1 2
Prev: CVAPI(void)
Next: solutions manuals