typedef..... - C
This is a discussion on typedef..... - C ; what does this code mean...
----------------------------------------------
typedef int RowArray[5];
RowArray *rptr;
-----------------------------------------
please reply..thank you..
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the ...
-
typedef.....
what does this code mean...
----------------------------------------------
typedef int RowArray[5];
RowArray *rptr;
-----------------------------------------
please reply..thank you..
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
-
Re: typedef.....
*rptr is a pointer to the array "RowArray" with a size of 5.
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
-
Re: typedef.....
sachin.gadkar@gmail.com wrote:
> what does this code mean...
>
> ----------------------------------------------
> typedef int RowArray[5];
This defines a type named RowArray which is an array of 5 ints.
> RowArray *rptr;
This uses the above type to describe a pointer to an array of 5 ints.
It is equivalent to:
int (*rptr)[5];
Hope this helps.
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
-
Re: typedef.....
sachin.gadkar@gmail.com a écrit :
> what does this code mean...
>
> ----------------------------------------------
> typedef int RowArray[5];
RowArray is an alias (synonym) to define a new type "array of 5 int" to
declare and define easily variables of this type.
RowArray arr; <=> int arr[5];
> RowArray *rptr;
rptr is a variable of type pointer to RowArray, then a variable of type
"pointer to array of 5 int".
It's a way to avoid writing complex things or making errors when you
combine several types.
e.g: "int * rptr[5];". In this case, rptr is no more a pointer to array
of 5 int as expected but an array of 5 pointers to int. The correct
writing is "int (*rptr)[5];"
Regis
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
Similar Threads
-
By Application Development in forum Java
Replies: 62
Last Post: 12-25-2007, 05:19 PM
-
By Application Development in forum CSharp
Replies: 1
Last Post: 12-12-2007, 10:56 AM
-
By Application Development in forum c++
Replies: 4
Last Post: 07-25-2007, 07:49 PM
-
By Application Development in forum c++
Replies: 0
Last Post: 02-23-2007, 04:51 PM
-
By Application Development in forum C
Replies: 2
Last Post: 08-21-2005, 12:48 AM