Difference between revisions of "C: Ponteiro para array"

From AdonaiMedrado.Pro.Br
Jump to: navigation, search
(New page: <code lang="c"> #include <stdio.h> #define TAMANHO_VETOR 10 int main(void) { int v[10]; int i; int *p=v; printf("%p (p)==%p (v)\n",p,v); printf("%p (&p)==%p (&v)\n",&p,&v); for(i=...)
 
Line 5: Line 5:
 
int main(void)
 
int main(void)
 
{
 
{
int v[10];
+
int v[TAMANHO_VETOR];
 
int i;
 
int i;
 
int *p=v;
 
int *p=v;

Revision as of 01:45, 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;
}