69,368
社区成员
发帖
与我相关
我的任务
分享
void swap1(char *s1, char *s2)
{
char *tmp;
tmp = s1;
s1 = s2;
s2 = tmp;
}
void swap2(char **s1, char **s2);
{
char *tmp;
tmp = *s1;
*s1 = *s2;
*s2 = tmp;
}
int main()
{
char *p1 = "str1";
char *p2 = "str2";
swap1(p1, p2); // 执行后,p1 和 p2 没改变
swap2(&p1, &p2); // 执行后,p1 和 p2 值交换
return 0;
}
createlist(linklist l,int n_first,int n_last)
typedef struct lnode
{
int data;
struct lnode *next;
}lnode,*linklist;
int createlist(linklist l,int n_first,int n_last)
{
int i,j;
linklist p,q;
l=(linklist)malloc(sizeof(struct lnode));
j=n_last;
q=l;
for(i=n_first;i <=j;i++)
{
p=(linklist)malloc(sizeof(struct lnode));
p->data=i;
q->next=p;
q=q->next;
}
q->next=NULL;
return 1;
}
int output(linklist l)
{
linklist p;
p=l->next;
while(p)
{
printf("%d ",p->data);
p=p->next;
}
printf("\n");
return 1;
}
void main()
{
linklist l;
int i =0,j=5;
createlist(l,i,j) ;
}