---
title: "指针学习笔记"
author: "microjava"
date: "2010-01-21T14:40:06Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2010-01-21T15:13:42Z"
id: 576479
url: "https://microjava.iteye.com/blog/576479"
---

```c

main()
{
  int a,b;
  int *p1,*p2;

  a=100;
  b=10;

  p1=&a;
  p2=&b;

  printf("%d,%d\n",a,b);
  printf("%d,%d\n",*p1,*p2);
}


```



```c

main()
{
  int *p1,*p2,*p,a,b;
  scanf("%d,%d",&a,&b);

  p1=&a;p2=&b;
  if(a<b)
  {
    p=p1;
    p1=p2;
    p2=p;
  }
  printf("\na=%d,b=%d\n",a,b);
  printf("max=%d,min=%d\n",*p1,*p2);
}


```



```c

main()
{
  char *str="I love C.";
  char *ps="this is a book";
  int n=10;
  
  printf("%s\n",str);

  ps=ps+n;
  printf("%s\n",ps);
}


```



```c

main()
{
  char *name[]={"Java","C","SQL","C++","javascript"};
  char **p;
  int i;
  for(i=0;i<5;i++)
  {
    p=name+i;
    printf("%s\n",*p);
  }
}


```