Difference between revisions of "C: Ponteiro para array"

From AdonaiMedrado.Pro.Br
Jump to: navigation, search
 
Line 10: Line 10:
  
 
printf("%p (p)==%p (v)\n",p,v);
 
printf("%p (p)==%p (v)\n",p,v);
printf("%p (&p)==%p (&v)\n",&p,&v);
+
printf("%p (&p)!=%p (&v)\n",&p,&v);
  
 
for(i=0;i<TAMANHO_VETOR;i++)
 
for(i=0;i<TAMANHO_VETOR;i++)

Latest revision as of 16:35, 17 April 2009

#include <stdio.h>
#define TAMANHO_VETOR 10
 
int main(void)
{
	int v[TAMANHO_VETOR];
	int i;
	int *p=v;
 
	printf("%p (p)==%p (v)\n",p,v);
	printf("%p (&p)!=%p (&v)\n",&p,&v);
 
	for(i=0;i<TAMANHO_VETOR;i++)
		scanf("%d",v+i);
	for(i=0;i<TAMANHO_VETOR;i++)
		printf("%d\n",*(p+i));
	return 0;
}