24/12/2020, 13:52
em bị lỗi "too few arguments to function call" xin các ac cao nhân chỉ giúp em
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct lisOfBook
{
char name[30];
char author[30];
float ID[10];
char category[20];
int status; //==0 neu da tra, ==1 nau da muon
}book;
void showMenu() //khai bao ham
{
printf("Press 1 to ADD books into booklist\n");
printf("Press 2 to search a book by name\n");
printf("Press 3 to display booklist\n");
printf("Press 4 to borrow booklist\n");
printf("Press 5 to return booklist\n");
printf("Press 6 to EXIT");
printf("Choose");
}
void inputBookist(book *P) //nhap lieu kieu con tro
{
int i;
for ( i = 0; i < 10; i++)
{
printf("Enter name of book %d :", i+1);
fflush(stdin);fflush(stdout);
gets(P[i].name);
printf("Enter author of book %d :", i+1);
fflush(stdin);fflush(stdout);
gets(P[i].author);
printf("Enter ID of book %d :", i+1);
fflush(stdin);fflush(stdout);
scanf("%d", &P[i].ID);
printf("Enter category of book %d :", i+1);
fflush(stdin);fflush(stdout);
gets(P[i].category);
}
}
void displayBookList(book *P) // ham hien thi
{
int i; // header
printf("\n");
for ( i = 0; i < 95; i++)
{
printf("-");
}
printf("\n|%30s|%30s|%10s|%20s","Name","Author","ID","Category");
printf("\n");
for ( i = 0; i < 95; i++)
{
printf("-");
}
for ( i = 0; i < 5; i++)
{
printf("\n|%30s|%30s|%10f|%20s",P[i].name,P[i].author,P[i].ID,P[i].category);
printf("\n");
for ( i = 0; i < 95; i++)
{
printf("-");
}
}
}
void sort(book *P) //ham sap xep
{
int i,j;
for ( i = 0; i < 3; i++){
for ( j = i+1; i < 4; j++)
{
int comp = strncmp(P[i].name, P[j].name);
if (comp > 0)
{ // swap book
book tmp = P[i];
P[i] = P[j];
P[j] = tmp;
}
}
}
}
int bookList(int argc, char *argv[]){
book bookList[10];
int choose;
do {
showMenu();
scanf("%d", &choose);
switch (choose)
{
case 1:
inputBookList(bookList);
break;
case 2:
break;
case 3:
sort(bookList); // goi ham sap xep
displayBookList(bookList);
break;
case 4:
break;
case 5:
break;
case 6:
printf("\nGood Bye !!!");
break;
default:
printf("\nNhap sai !!!");
break;
}
}while(choose != 7);
};
Bài liên quan
em bị lỗi dòng này ạ " int comp = strncmp(P[i].name, P[j].name);"