指针当传参无论怎么改变地址都不会影响其实参的地址

#include
void swap(char* head,char* tail);
int main(int argc, const char *argv[])
{
	char buff[]="love china";//answer:china love I
	char* head=buff;
	char* tail=buff;
	printf("实参(1)%p\t%p\n",head,tail);
	while(*tail!='\0')
		tail++;
	swap(buff,tail-1);
	printf("实参(2)%p\t%p\n",head,tail);
	putchar(10);
	while(*head!='\0')
	{
		while(*head==32)
		{
			head++;
		}
		tail=head;
		while(*tail!=32&&*tail!='\0')
		{
			tail++;
		}
		printf("实参(3)%p\t%p\n",head,tail);
		swap(head,tail-1);
		printf("实参(3)%p\t%p\n",head,tail);
		head=tail;

		putchar(10);
	}
	puts(buff);
	return 0;
}

void swap(char* head,char* tail)
{
	while(head

指针当传参无论怎么改变地址都不会影响其实参的地址_第1张图片

你可能感兴趣的:(linuxC语言初学者)