首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

C primer plus 中usehotel的例证,求解

2013-01-23 
C primer plus 中usehotel的例子,求解?这是hotel.c中的代码:#includestdio.h#include hotel.h#define

C primer plus 中usehotel的例子,求解?
这是hotel.c中的代码:

#include<stdio.h>
#include "hotel.h"
#define STARS *******************
int menu(void)
{
    int code, status;
    
    
    
    printf("\n%s%s\n", STARS, STARS);
    printf("Enter the number of the desired hotel: \n");
    printf("1) Fairfied Arms     2) Hotel Olympic\n");
    printf("3) Chertowrthy Plaza 4) The Stockton\n");
    printf("5) quit\n");

    printf("%s%s\n", STARS, STARS);
    
   while( (status = scanf("%d", &code)) != 1 
        || (code < 1 || code > 5))
    {
        if(status != 1) {
        //scanf("%*s", "");
            printf("Enter an integer from 1 to 5, please.\n");
        }
    }

    return code;
}

int getnights(void)
{
    int nights;
    
    return nights;
}

void showprice(double rate, int nights)
{
     int n;
     double total = 0.0;
     double factor = 1.0;
     
     printf("The total cost will be $%0.2f.\n", total);


}


编译的时候出现:



如果代码改成这样:
#include<stdio.h>
#include "hotel.h"
#define STARS *******************
int menu(void)
{
    int code, status;
    
    
    
    printf("\n%s%s\n", "*******************", "*******************");
    printf("Enter the number of the desired hotel: \n");
    printf("1) Fairfied Arms     2) Hotel Olympic\n");
    printf("3) Chertowrthy Plaza 4) The Stockton\n");
    printf("5) quit\n");

    printf("%s%s\n", "*******************", "*******************");
    
   while( (status = scanf("%d", &code)) != 1 
        || (code < 1 || code > 5))
    {
        if(status != 1) {
        //scanf("%*s", "");
            printf("Enter an integer from 1 to 5, please.\n");
        }
    }

    return code;


}

int getnights(void)
{
    int nights;
    
    return nights;
}

void showprice(double rate, int nights)
{
     int n;
     double total = 0.0;
     double factor = 1.0;
     
     printf("The total cost will be $%0.2f.\n", total);


}





难道这样定义不行吗?
#define STARS *******************


编译的错误信息:
编译器: Default compiler
Building Makefile: "J:\C语言学习\Makefile.win"
执行  make...
make.exe -f "J:\C语言学习\Makefile.win" all
gcc.exe -c hotel/hotel.c -o hotel/hotel.o -I"C:/Dev-Cpp/include"  -I"J:/C语言学习/总结"   

hotel/hotel.c: In function `menu':
hotel/hotel.c:10: error: syntax error before ',' token

make.exe: *** [hotel/hotel.o] Error 1

执行结束

求解???

热点排行