poss soln

M

mehul raval

hi ,
regarding ur query as to print the individual elements here is the
poss way to do it.
# include <stdio.h>

void main()
{
int (*Data)[4];
int A[4]={1,2,3,4};
Data=&A;

/* A is a pointer to an array of 4 int.*/

printf(" %d %d",*((*Data)),*((*Data)+1));
return;
}
this prog will print both the elements and similarly all the elements
can be printed with the format *((*Data)+ i).
in the prog u had initalized Data to be a ptr to a 2D array with the
no of columns specified but the no rows werent.
*Data pts to the 1st row in such case and then other rows can be
accessed by *(Data)+ (rowno) and llly the contents by *(*(Data)+
(rowno)),thats the format.
Hope it helps.
mehul
 
C

CBFalconer

mehul said:
regarding ur query as to print the individual elements here is the
poss way to do it.
.... snip ...

What language is that? It is not C, which is on topic, nor
English, often used to describe C matters. Ur is an ancient city
in Mesopotamia, and should be capitalized. I can't imagine what a
poss is.

i.e. kindly do not use cryptic abbreviations in c.l.c.
 
P

pete

mehul said:
hi ,
regarding ur query as to print the individual elements here is the
poss way to do it.
# include <stdio.h>

void main()
{
int (*Data)[4];
int A[4]={1,2,3,4};
Data=&A;

/* A is a pointer to an array of 4 int.*/

printf(" %d %d",*((*Data)),*((*Data)+1));
return;
}
this prog will print both the elements and similarly all the elements
can be printed with the format *((*Data)+ i).
in the prog u had initalized Data to be a ptr to a 2D array with the
no of columns specified but the no rows werent.
*Data pts to the 1st row in such case and then other rows can be
accessed by *(Data)+ (rowno) and llly the contents by *(*(Data)+
(rowno)),thats the format.
Hope it helps.

It doesn't.

When I read the subject line "poss soln",
I thought this was going to be a foreign language post.

There are no clues available as to what question
you think you're answering or to who you think you're talking to.
You started a new thread and quoted nothing.

The return type of main, is int.
void main is not defined by C.
 
J

Joona I Palaste

CBFalconer said:
... snip ...
What language is that? It is not C, which is on topic, nor
English, often used to describe C matters. Ur is an ancient city
in Mesopotamia, and should be capitalized. I can't imagine what a
poss is.
i.e. kindly do not use cryptic abbreviations in c.l.c.

I would have written the same reply but thought I'd get branded as an
English language spelling N... zealot.
As well as the h4x0r d00dsp33k, the post contained several apparently
unintentional spelling errors. I would suggest learning to spell
properly FIRST, and THEN, if you feel the need, use cute script kiddie
tricks.
Whoever told you (mehul raval) that writing like a 10-year-old spotty
kid makes you more respected was talking complete garbage. On technical
forums like this, it makes you *LESS* respected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top