Let's take a look at how to change the warning of this program.

Source: Internet
Author: User
Let's take a look at how to change the warning of this program-Linux general technology-Linux programming and kernel information. The following is a detailed description. Main. c
# Include
# Include
# Include "lianbiao. h"
/* # Include
# Define maxname 100
# Define stu struct student
Typedef struct {
Char name [maxname];
Int num;
Int math;
Int chinese;
Stu * next;
} Student ;*/
Int main ()
{
Student * head;
Student * pl;
Head = (student *) malloc (sizeof (student ));
Int a, number, c;
C = 0;
Printf ("now creat a student 'date \ n ");
Printf ("% d", c );
Head = creat ();
While (c = 0 ){
Printf ("what do you want to do? \ N ");
Printf ("please input 0 (exit), 1 (del a student), 2 (add student), 3 (find a student), 4 (display) \ n ");
Scanf ("% d", & );
Switch (){
Case 0: c = 1; break;
Case 1: printf ("please input the student's number: \ n ");
Scanf ("% d", & number );
Head = del (number, head); break;
Case 2: printf ("now start to add: \ n ");
Head = add (head); break;
Case 3: printf ("please input the student's number: \ n ");
Scanf ("% d", & number );
Pl = find (number, head); break;
Case 4: head = display (head); break;
Default: c = 1; break;
}

}

}
Lianbiao. h
// # Define stu struct student
# Define maxname 100
Typedef struct {
Char name [maxname];
Int num;
Int math;
Int chinese;
Struct student * next;
} Student;
Student * creat (void );
Student * del (int number, student * p );
Student * add (student * p );
Student * find (int number, student * p );
Student * display (student * p );
Lianbiao. c
# Include
# Include
# Include
# Include "lianbiao. h"
Student * creat (void ){
Student * p1;
Student * p2;
Student * p;
P1 = (student *) malloc (sizeof (student ));
P1-> next = NULL;
P2 = p1;
While (1 ){
P = (student *) malloc (sizeof (student ));
Printf ("please input student's number from small to large \ n ");
Scanf ("% d", & p-> num );
If (p-> num = 0) break;
Printf ("please input student's name \ n ");
Scanf ("% s", & p-> name );
Printf ("please input student's math number \ n ");
Scanf ("% d", & p-> math );
Printf ("please input student's chinese number \ n ");
Scanf ("% d", & p-> chinese );
If (p2-> next = NULL ){
P1-> next = p; p-> next = NULL; p1 = p; printf ("chenggong \ n ");}
Else {p1-> next = p; p-> next = NULL; p1 = p; printf ("chenggong \ n ");}
} Return (p2 );
}

Student * del (int number, student * p ){
Student * p1;
Student * p2;
P1 = p2 = p;
If (p-> next = NULL) printf ("eror: this lianbiao is null! ");
// If (p-> num = number) p2 = p-> next;
If (p-> num = number) p2 = p-> next;
Else p = p-> next;
While (p-> num! = Number & p-> next! = NULL ){
P1 = p; p = p-> next;
}
If (p-> next = NULL) printf ("eror: there is no this student! ");
P1-> next = p-> next;
Free (p );
Return (p2 );
}

Student * add (student * p ){
Int number;
Student * p1;
Student * p2;
Student * p3;
If (p-> next = NULL) printf ("eror: this lianbiao is null! ");
P2 = p;
P = p-> next;
Printf ("please input student's number \ n ");
Scanf ("% d", & number );
While (p-> num <number & p-> next! = NULL ){
P = p-> next;
} Printf ("chenggong \ n ");
If (p-> num = number) {printf ("eror: this student is cunzai! "); Return (p2 );}
P3 = (student *) malloc (sizeof (student ));
P3-> num = number;
Printf ("please input student's name \ n ");
Scanf ("% s", & p3-> name );
Printf ("please input student's math number \ n ");
Scanf ("% d", & p3-> math );
Printf ("please input student's chinese number \ n ");
Scanf ("% d", & p3-> chinese );
If (p-> next = NULL) {p-> next = p3; p3-> next = NULL; p = p3 ;}
Else {p3-> next = p;
P1-> next = p3 ;}
Return (p2 );
}
Student * find (int number, student * p ){
Int I = 0;
If (p-> next = NULL) printf ("eror: this lianbiao is null! ");
While (p-> num! = Number & p-> next! = NULL ){
P = p-> next; I ++;
}
If (p-> next = NULL)
If (p-> num! = Number)
Printf ("eror: this student is not egzist! ");
Printf ("chenggong \ n ");
Printf ("% d", I );
Printf ("% d, % d, % s, % d \ n", p-> num, p-> math, p-> name, p-> chinese );
Return (p );
}
Student * display (student * p)
{
Student * p1;
Student * p2;
P2 = p;
P1 = p-> next;
While (p1-> next! = NULL ){
Printf ("% d, % s, % d, % d \ n", p1-> num, p1-> name, p1-> math, p1-> chinese );
P = p1; p1 = p1-> next;
}
Printf ("% d, % s, % d, % d \ n", p1-> num, p1-> name, p1-> math, p1-> chinese );
Return (p2 );
}
The following warning is prompted when lianbiao. o is generated:
Lianbiao. c: In the 'creat' function:
Lianbiao. c: 24: Warning: incompatible pointer type assignment
Lianbiao. c: 25: Warning: Assignment of incompatible pointer types
Lianbiao. c: In the 'del 'function:
Lianbiao. c: 35: Warning: incompatible pointer type assignment
Lianbiao. c: 36: Warning: incompatible pointer type assignment
Lianbiao. c: 38: Warning: incompatible pointer type assignment
Lianbiao. c: In the 'add' function:
Lianbiao. c: 53: Warning: incompatible pointer type assignment
Lianbiao. c: 57: Warning: Assignment of incompatible pointer types
Lianbiao. c: 68: Warning: incompatible pointer type assignment
Lianbiao. c: 69: Warning: incompatible pointer type assignment
Lianbiao. c: 70: Warning: incompatible pointer type assignment
Lianbiao. c: In the 'Find 'function:
Lianbiao. c: 77: Warning: Assignment of incompatible pointer types
Lianbiao. c: In the 'display' function:
Lianbiao. c: 92: Warning: incompatible pointer type assignment
Lianbiao. c: 95: Warning: Assignment of incompatible pointer types
Related Article

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.