Difference between revisions of "C: Ponteiro para string"

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

Latest revision as of 16:58, 17 April 2009

#include <stdio.h>
#include <string.h>
 
int main(void)
{
	char s[11];
	int i;
	char *p=s;
 
	printf("%p (p)==%p (s)\n",p,s);
	printf("%p (&p)!=%p (&s)\n",&p,&s);
 
	scanf("%s",s);
 
	for(i=0;i<strlen(s);i++)
		printf("%c",*(p+i));
	return 0;
}