#include <stdio.h>
void swap(int *x, int *y);
void main()
{
int iNum1, iNum2;
iNum1 = 10;
iNum2 = 20;
swap(&iNum1, &iNum2);
printf(“iNum1=%d,iNum2=%d” ,iNum1,iNum2);
}
void swap(int *pi1, int *pi2)
{
int temp;
temp = *pi1;
*pi1 = *pi2;
*pi2 = temp;
}
#include <stdio.h>
int main(){
static int ary[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int I,*p=NULL;
for (i = 0; i < 10; i ++){
printf("\ni=%d,ary[i]=%d,*(ary+i)=%d",i,ary[i],*(ary + i));
printf("&ary[i]= %X,ary+i=%X",&ary[i],ary+i);
}
for (p = ary; p < ary+10 ; p++){ /*能否使用ary++?*/
printf(“\naddress:%x,value:%d”,p,*p);
}
return 0;
}
#include <stdio.h>
#include <string.h>
void main ()
{ char a, str[81], *ptr;
printf("请输入一个字符串\n ");
gets(str);
printf("\n请输入一个字符");
a = getchar();
ptr = strchr(str,a);
if(ptr != NULL)
printf(“\nPosition of first occurrence is: %d”,ptr-str);
else printf(“not found!”);
}