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...)
(No difference)

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