这个时候&s指向字符串的第一个字符的地址,所以屏幕上输出的是d。
&s+1后,p指针的地址直接跳到了字符串的最后'\0',这个时候屏幕上输出是'\0'。
注意这个位置的标志。(p-2)是常量,不是变量。因为字符串在前面定义的常量。屏幕上的输出h。并且在d与h之间有一个空白,因为前面输出一个字符'\0'。
#include "stdio.h"#include "string.h"
void main()
{
char a[81]=""
char *p=a
int n,k,pos
puts("input the data")
gets(a)
n=strlen(a)
puts("the position you want to delete")
scanf("%d",&k)
for (p=&a[k-1]p<=a+np++)
{
char temp
temp=*p
*p=*(p+1)
*(p+1)=temp
}
*p=0
puts(a)
}
#include "stdio.h"
#include "string.h"
void main()
{
char a[5]=""
char *p[5]
char *max
for (int i=0i<5i++)
{
p[i]=&a[i]
}
puts("input five num")
for (i=0i<5i++)
{
fflush(stdin)
scanf("%c",&a[i])
}
for (i=0,max=p[i]i<5i++)
{
if (*p[i]>*max)
{
*max=*p[i]
}
}
printf("%c",*max)}