Keyboard input Chain List 1

Source: Internet
Author: User

#include <stdio.h>
#include <malloc.h>
Keyboard input Chain List

struct wyq{
Char name[100];
int age;
Char address[100];
struct Wyq*next;
};

int main ()
{
struct wyq*
Head
struct wyq*p;
struct wyq*q;
int i;

head= (struct wyq*) malloc (sizeof (struct wyq));
if (null==head) {
printf ("No successful Application");
Exit (-1);
}

printf ("Input list node content: \ n");
printf ("Name--");
scanf ("%s", head->name);
printf ("Age");
scanf ("%s", head->age);
printf ("Address,");
scanf ("%s", head->address);
head->next=null;


P=head;
Q=head;

printf ("1; continue; 2 stop \ n");
scanf ("%d", &i);
while (i==1) {
p= (struct wyq*) malloc (sizeof (struct wyq));
printf ("Input list node content: \ n");
printf ("Name--");
scanf ("%s", p->name);
printf ("Age");
scanf ("%s", p->age);
printf ("Address,");
scanf ("%s", p->address);
p->next=null;

q->next=p;
Q=p;

printf ("1; continue; 2 stop \ n");
scanf ("%d", &i);

if (i==2) {
Break
}
}


return 0;
}

Keyboard input Chain List 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.