帮忙修改以下的C语言程序!使他能正常运行

来源:百度知道 编辑:UC知道 时间:2024/06/17 22:18:52
#include<stdio.h>
struct sf{
char *s;
struct sf *psf;
}
main()
{
static struct sf x[]={{"abcde",x+1},
{"fghij",x+2},
{"klmno",x}};
struct sf *p[];
int i;
for(i=0;i<3;i++) p[i]=x[i].psf;
printf("(1)---%s*%s%s\n",(*p)->s,(**p).s,p[0]->s);
swap(*p,x);
swap(p[0],p[0]->psf);
printf("(3)---%s*%s\n",p[0]->s,(*++p[0]).s);
printf("(4)---%s\n",++(*++(*p)->psf).s);
}

swap(struct sf *p1,*p2)
{
char *temp;
temp=p1->s;
p1->s=p2->s;
p2->s=temp;
}

#include<stdio.h>

struct sf{
char *s;
struct sf *next;
};

void swap(struct sf *p1,struct sf *p2);
void main()
{
static struct sf x[]={{"abcde",x+1},{"fghij",x+2},{"klmno",x}};

struct sf *p[100];

for(int i=0;i<3;i++)
{
p[i]=x[i].next;
}
printf("(1.0)---%s * %s %s\n",(*p)->s,(**p).s,p[0]->s);

swap(p[0],x) ;
printf("(1.1)---%s * %s %s\n",(*p)->s,(**p).s,p[0]->s);
swap(p[0],p[0]->next);
printf("(2.1)---%s * %s %s\n",(*p)->s,(**p).s,p[0]->s);

printf("(3.0)---%s*%s\n",p[0]->s,(*++p[0]).s);

printf("(4.0)---%s\n",++(*++(*p)->next).s);
}

void swap(struct sf *p1,struct sf *p2)
{
char *temp;
temp=p1->s;
p1->s=p2->s;
p2->s=temp;
}