菜鸟每天问之。。。。链串的问题~~
#include<stdio.h>typedef struct student///////串链{ char a[5]; struct student *next;}stu1;newstring(stu1 *s)//////////////////窜链的初始{ s=(stu1 *)malloc(sizeof(stu1)); s->next=NULL;}withstring(stu1 *s1,char *s2)/////////////////////串链的赋值{ stu1 *p,*q; int i=0,j=0,t; p=s1; t=strlen(s2); for(;i<t;i++,j++){ p->a[i]=s2[j]; if(i==3){ q=(stu1 *)malloc(sizeof(stu1)); p->next=q; p=q; i=0;}}p->next=NULL;p->a[i]='\0';}print(stu1 *s){ stu1 *q; q=s; while(q!=NULL) { puts(q->a); q=q->next; }}main(){ char a[100]; stu1 b; newstring(&b); gets(a); withstring(&b,a); print(&b);}