|
From: dawood <da...@ku...> - 2003-07-10 21:03:16
|
1.does anybody know how to create a typedef for an array of 8 arrays of 7
pointers to int.
2. char c[]="hello";
char* pc= c;
char** ppc = &pc;
does anybody know a much shorter method to create a pointer to
pointer to char. I am doing it in 3 statements. Can anybody show me how to
do it in less than 3 statements.
3. Also can anybody show me how to create a non constant reference to
pointer to pointer to char.
|
|
From: Graham D. <g.d...@nt...> - 2003-07-10 21:35:25
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"> <title></title> </head> <body> Sounds like homework....<br> <br> 3. There's no such thing as a non constant reference. All references are "constant" in that they are not reseatable.<br> <br> dawood wrote:<br> <blockquote type="cite" cite="mid...@ku..."><font face="Courier New, Courier">1.does anybody know how to create a typedef for an array of 8 arrays of 7 pointers to int.<br> <br> 2. char c[]="hello";<br> char* pc= c;<br> char** ppc = &pc;<br> <x-tab> </x-tab>does anybody know a much shorter method to create a pointer to pointer to char. I am doing it in 3 statements. Can anybody show me how to do it in less than 3 statements. <br> 3. Also can anybody show me how to create a non constant reference to pointer to pointer to char.<br> </font></blockquote> </body> </html> |
|
From: Ioannis V. <iv...@em...> - 2003-07-10 21:45:59
|
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of dawood
Sent: Thursday, July 10, 2003 11:36 PM
To: Dev C++
Subject: [Dev-C++] three queries
1.does anybody know how to create a typedef for an array of 8 arrays of =
7
pointers to int.
2. char c[]=3D"hello";
char* pc=3D c;
char** ppc =3D &pc;
does anybody know a much shorter method to create a pointer to
pointer to char. I am doing it in 3 statements. Can anybody show me how =
to
do it in less than 3 statements. =20
=20
=20
At first you should mention language, i assume C.
=20
A typedef? I do not see any typedef above. Perhaps today i have had much
critical mood but do you know what you are doing above?
=20
You create a char array in the automatic storage and then you point to =
the
first element of it using a char pointer and you point to that char =
pointer
using a pointer to char pointer.
=20
=20
If you want to access the first element of the array using the char ** =
you
can do directly:
=20
char c[]=3D"hello";
=20
char **ppc=3Dc;
=20
=20
3. Also can anybody show me how to create a non constant reference to
pointer to pointer to char.=20
=20
Well, you are talking about C++. You can't do that. You can use =
references
to pointers only to templates.
=20
=20
Example:
=20
template <class T>
inline T &rfer(T &r) { return r; }
=20
=20
But the above is useless.
=20
=20
=20
=20
=20
Ioannis Vranos
* Programming pages: <http://www.noicys.freeurl.com/>
http://www.noicys.freeurl.com
* Alternative URL 1: <http://run.to/noicys> http://run.to/noicys
* Alternative URL 2: <http://www.noicys.cjb.net/> =
http://www.noicys.cjb.net
|
|
From: Ioannis V. <iv...@em...> - 2003-07-10 21:55:33
|
-----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of dawood Sent: Thursday, July 10, 2003 11:36 PM To: Dev C++ Subject: [Dev-C++] three queries 1.does anybody know how to create a typedef for an array of 8 arrays of 7 pointers to int. My mistake i had not seen the '1', so i answer it here: A direct answer (if i got what you want correctly): typedef int *ar[8][7]; Also you can reach your goal gradually: typedef int *par[7]; typedef par ppar[8]; This is an array of 8 pars which means it is an array of 8 arrays of 7 int * each. Another example to help you understand how typedef makes our lives better: typedef char char_array[10]; typedef char_array m_char_array[2]; m_char_array a; What is a? :-) Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com <http://www.noicys.freeurl.com/> * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |
|
From: Per W. <pw...@ia...> - 2003-07-11 02:13:04
|
Is this a school assignment? If not, I would be more interested in what you want to solve. A lot of the time there are a number of questions how to write this and that complicated construct, when the original problem might have a simpler solution. What triggers my question is that a reference to a pointer to a pointer to char is a tripple indirection, since a reference is just a modified form of a pointer. Do you really, really need such a long way just to get in contact with a poor little character :-) Ioannis: My assumption about a question of a non-const reference is not if the reference may be changed, but if the object pointed to by the reference may be modified. /Per W On Fri, 11 Jul 2003, dawood wrote: > 1.does anybody know how to create a typedef for an array of 8 arrays of 7 > pointers to int. > > 2. char c[]="hello"; > char* pc= c; > char** ppc = &pc; > does anybody know a much shorter method to create a pointer to > pointer to char. I am doing it in 3 statements. Can anybody show me how to > do it in less than 3 statements. > 3. Also can anybody show me how to create a non constant reference to > pointer to pointer to char. > |
|
From: Ioannis V. <iv...@em...> - 2003-07-11 03:47:22
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Per Westermark > Sent: Friday, July 11, 2003 5:15 AM > To: dawood > Cc: Dev C++ > Subject: Re: [Dev-C++] three queries > > > Ioannis: My assumption about a question of a non-const > reference is not if > the reference may be changed, but if the object pointed to by the > reference may be modified. That is my assumption too. The other assumption you are mentioning, is someone else's assumption. :-) Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |