PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.c > What is the difference between: int a (*daytab)[13] and int a*daytab[13]
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
What is the difference between: int a (*daytab)[13] and int a*daytab[13]

Réponse
 
LinkBack Outils de la discussion
Vieux 04/05/2008, 19h49   #1
magicman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut What is the difference between: int a (*daytab)[13] and int a*daytab[13]

thx
  Réponse avec citation
Vieux 04/05/2008, 19h59   #2
Tomás Ó hÉilidhe
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What is the difference between: int a (*daytab)[13] and int a*daytab[13]


int (*)[13] Pointer to an array of 13 int's.


int *[13] Array of 13 pointers to int's.
  Réponse avec citation
Vieux 04/05/2008, 20h03   #3
Bartc
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What is the difference between: int a (*daytab)[13] and int a *daytab[13]


"magicman" <ironsel2000@gmail.com> wrote in message
news:11cc16fd-e18d-423d-a226-e02dbd62d0bc@k13g2000hse.googlegroups.com..

[What is the difference between: int a (*daytab)[13] and int a
*daytab[13]]

As written: nothing, they're both syntax errors.

On the other hand, int (*daytab)[13] is a pointer to an array of 13 ints.

While int *daytab[13] is an array of 13 pointers to ints.

(Thanks to a program cdecl.exe I've just downloaded. Otherwise I wouldn't
have a clue either. And the existence of such a program suggests I'm not
alone!)

--
Bartc


  Réponse avec citation
Vieux 04/05/2008, 20h57   #4
santosh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What is the difference between: int a (*daytab)[13] and int a *daytab[13]

magicman wrote:

> What is the difference between: int a (*daytab)[13] and int a
> *daytab[13]
> thx


In a declaration the first one declares daytab as a pointer to an array
of 13 ints. The second declares daytab as an array of 13 int*.

For the first one

daytab[n]

will be of type int and for the second one

daytab[n]

will be of type int*.

PS. For 0 <= n <= 12 of course.

  Réponse avec citation
Vieux 04/05/2008, 21h42   #5
Ben Bacarisse
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What is the difference between: int a (*daytab)[13] and int a *daytab[13]

santosh <santosh.k83@gmail.com> writes:

> magicman wrote:
>
>> What is the difference between: int a (*daytab)[13] and int a
>> *daytab[13]
>> thx

>
> In a declaration the first one declares daytab as a pointer to an array
> of 13 ints. The second declares daytab as an array of 13 int*.


I guess you are ignoring the "a" in both!

> For the first one
>
> daytab[n]
>
> will be of type int


It will be of type "array of 13 int". It will be converted to an int
pointer in most contexts hence, I suspect, the confusion.

> and for the second one
>
> daytab[n]
>
> will be of type int*.


Yes, in both cases daytab[n] could be further subscripted or passed to
function that expects and int *.

--
Ben.
  Réponse avec citation
Vieux 04/05/2008, 21h46   #6
santosh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What is the difference between: int a (*daytab)[13] and int a *daytab[13]

Ben Bacarisse wrote:

> santosh <santosh.k83@gmail.com> writes:
>
>> magicman wrote:
>>
>>> What is the difference between: int a (*daytab)[13] and int a
>>> *daytab[13]
>>> thx

>>
>> In a declaration the first one declares daytab as a pointer to an
>> array of 13 ints. The second declares daytab as an array of 13 int*.

>
> I guess you are ignoring the "a" in both!


Oops! I'm starting to really believe the research indications that the
brain "reads" what it "wants to read", or "completes" sentences from
partially reading them. Thanks once again for the correction.

>> For the first one
>>
>> daytab[n]
>>
>> will be of type int

>
> It will be of type "array of 13 int". It will be converted to an int
> pointer in most contexts hence, I suspect, the confusion.
>
>> and for the second one
>>
>> daytab[n]
>>
>> will be of type int*.

>
> Yes, in both cases daytab[n] could be further subscripted or passed to
> function that expects and int *.
>


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h41.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16915 seconds with 14 queries