2
Error in C
SofhinWong1 (3)

#include <stdio.h>
#include<string.h>
#include<stdlib.h>

//variable for A1
int menu;
char Name[100];
char Student_ID[100];
char Room[100];
char Bill[100];
int Meal, Gym, Week;

int main(){
printf("1 Room Booking\n2 Room Availability\n3 Payment Details\nPlease enter your option:");
scanf("%i",&menu);
if(menu==1){
A1:
printf("\nPlease enter your name:");
scanf(" %c",&Name);
printf("\nPlease enter your Student ID:");
scanf("%c",& Student_ID);
printf("\n\nPlease choose your gender.\n1 Male\n2 Female");
goto A1;
}
}

When I run the program, it gives me warning.
warning: format specifies type 'char ' but the argument has type 'char ()[100]' [-Wformat]
May I know how to fix it?

You are viewing a single comment. View All
1
SofhinWong1 (3)

@mwilki7 BTW, I want to ask like how to auto assign a number for the user?
here is my code. I want to auto assign the room no for the user when they book the room. Is it possible? And I use for loop, am I write it correctly? Is this in a loop dy?

#include <stdio.h>
#include<string.h>
#include<stdlib.h>

void Room_Type(){
printf("\n1 Single Room\n2 Double Bedded Room\n3 Triple Bedded Room\n4 Four Beeded Room\n5 Main Menu\nPlease enter your option: ");}

int main(){
//variable for menu1
int menu, GDR,i,pay,Laundry_rate=20;
//variables for A1
char A1_Name=malloc(100);
char
A1_SID=malloc(100);
char *A1_Room=malloc(100);
int choose,I_week, L_week,R_week;
int A1_Internet, A1_Laundry, A1_Gym, A1_Meal,A1_total;
int A1_room_rate=400, A1_Internet_rate=40;

//variables for A3
charA3_Name=malloc(100);
char
A3_SID=malloc(100);
char *A3_Room=malloc(100);
int A3_Internet, A3_Laundry, A3_Gym, A3_Meal, A3_room_rate=150, A3_Internet_rate=15;
int A3_L_week, A3_I_week, A3_R_week,A3_total;

//variables for A4
char A4_Name=malloc(100);
char
A4_SID=malloc(100);
char *A4_Room=malloc(100);
int A4_Internet, A4_Laundry, A4_Gym, A4_Meal, A4_room_rate=100, A4_Internet_rate=10;
int A4_L_week, A4_I_week, A4_R_week,A4_total;

//variable for B4
char B4_Name=malloc(100);
char
B4_SID=malloc(100);
char *B4_Room=malloc(100);
int B4_Internet, B4_Laundry, B4_Gym, B4_Meal, B4_room_rate=100, B4_Internet_rate=10;
int B4_L_week, B4_I_week, B4_R_week,B4_total;

//variable for menu2
int check;

int I_total, room_total, L_total,total;

for(i=0;i<=2;i++){
A1_Room[i]=0;
A3_Room[i]=0;
A4_Room[i]=0;
B4_Room[i]=0;
I_total=0;
L_total=0;
room_total=0;
A1_total=0;
A3_total=0;
A4_total=0;
B4_total=0;}

Main_Menu:
printf("\n1 Room Booking\n2 Room Availability\n3 Payment Details\nPlease enter your option:");
scanf("%i",&menu);

if(menu==1)
{
Details:
printf("\n\n1 Male\n2 Female\nPlease enter your option: ");
scanf("%i",&GDR);
Room_Type();
scanf("%i", & choose);}

//male+A1
if(GDR==1 && choose==1){
A1:
printf("\nHow many weeks of room booking?\n");
scanf("%i",&R_week);

Internet:
printf("\nDo you want to subscribe for Internet?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&A1_Internet);
if(A1_Internet==1){
A1_Internet_rate;
printf("How many weeks of subscription?\n");
scanf("%i",&I_week);}
if(A1_Internet==2){
A1_Internet=0;}

//Meal:
printf("\nDo you want to subscribe for Meal?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&A1_Meal);
if(A1_Meal==1 ){
printf("Sorry, this service is not available for subscription. Thank you.\n");}

//Laundry:
printf("\nDo you want to subscribe for Laundry?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&A1_Laundry);
if(A1_Laundry==1){
Laundry_rate;
printf("How many weeks of subscription?\n");
scanf("%i",&L_week);}
if(A1_Laundry==2){
A1_Laundry=0;}
//Gym
printf("\nDo you want to subscribe for Gym?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&A1_Gym);
if(A1_Gym==1 ){
printf("Sorry, this service is not available for subscription. Thank you\n");}

    printf("\nPlease enter your name:");
    scanf("%s", A1_Name);
    printf("Please enter your Student ID:");
    scanf("%s",A1_SID);
    room_total= A1_room_rate*R_week;
    L_total = Laundry_rate*L_week;
    I_total = A1_Internet_rate*I_week;
    total = room_total + I_total+L_total;
  
  Pay:
    printf("\n\nHere is your bill.\nWeekly rate for the room\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the laundry\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the Internet: RM%i\n%i weeks of subscription\t\t: RM%i\nTotal amount payable is RM%i.\n",A1_room_rate, R_week, room_total, Laundry_rate,L_week,L_total,A1_Internet_rate,I_week,I_total,total);
    printf("\nDo you want to make payment now or later by cash?\n1 Now\n2 Cash\nPlease enter your option:");
    scanf("%i",&pay);
    if(pay==1){
      printf("\nPlease deposit your money in the slot provided.\nMaximum cash per deposit is 100 pieces of any combined denominations.\n");
      printf("Thank you for your payment.\n\n");
      goto Main_Menu;}
    if(pay==2){
      printf("Please proceed to counter 1. Payment must be made within 7 days. Thank you.\n\n");
      goto Main_Menu;}
    else{
      goto Pay;}}

//male+A2
if(GDR==1 && choose==2){
A2:
printf("\nSorry. This block is not ready for occupancy.");
goto Details;}
//male+A3
if(GDR==1 && choose==3){
A3:
printf("\nHow many weeks of room booking?\n");
scanf("%i",&A3_R_week);

//Internet:
printf("\nDO you want to subscribe for Internet?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&A3_Internet);
if(A3_Internet==1){
A3_Internet_rate;
printf("How many weeks of subscription?\n");
scanf("%i",&A3_I_week);}
if(A3_Internet==2){
A3_Internet=0;}

//Meal:
printf("\nDo you want to subscribe for Meal?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&A3_Meal);
if(A3_Meal==1 ){
printf("Sorry, this service is not available for subscription. Thank you.\n");}

//Laundry:
printf("\nDo you want to subscribe for Laundry?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&A3_Laundry);
if(A3_Laundry==1){
Laundry_rate;
printf("How many weeks of subscription?\n");
scanf("%i",&A3_L_week);}
if(A3_Laundry==2){
A3_Laundry=0;}
//Gym
printf("\nDo you want to subscribe for Gym?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&A3_Gym);
if(A3_Gym==1 ){
printf("Sorry, this service is not available for subscription. Thank you\n");}

  printf("\nPlease enter your name:");
  scanf("%s", A3_Name);
  printf("Please enter your Student ID:");
  scanf("%s",A3_SID);
  room_total= A3_room_rate*A3_R_week;
  L_total = Laundry_rate*A3_L_week;
  I_total = A3_Internet_rate*A3_I_week;
  A3_total = room_total + I_total+L_total;

Pay2:
  printf("\n\nHere is your bill.\nWeekly rate for the room\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the laundry\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the Internet: RM%i\n%i weeks of subscription\t\t: RM%i\nTotal amount payable is RM%i.\n",A3_room_rate, A3_R_week, room_total, Laundry_rate,A3_L_week,L_total,A3_Internet_rate,A3_I_week,I_total,A3_total);
  printf("\nDo you want to make payment now or later by cash?\n1 Now\n2 Cash\nPlease enter your option:");
  scanf("%i",&pay);
  if(pay==1){
    printf("\nPlease deposit your money in the slot provided.\nMaximum cash per deposit is 100 pieces of any combined denominations.\n");
    printf("Thank you for your payment.\n\n");
    goto Main_Menu;}
  if(pay==2){
    printf("Please proceed to counter 1. Payment must be made within 7 days. Thank you.\n\n");
    goto Main_Menu;}
  else{
    goto Pay2;}}

//male+A4
if(GDR==1 && choose==4){
A4:
printf("\nHow many weeks of room booking?\n");
scanf("%i",&A4_R_week);

//Internet:
printf("\nDO you want to subscribe for Internet?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&A4_Internet);
if(A4_Internet==1){
A4_Internet_rate;
printf("How many weeks of subscription?\n");
scanf("%i",&A4_I_week);}
if(A4_Internet==2){
A4_Internet=0;}

//Meal:
printf("\nDo you want to subscribe for Meal?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&A4_Meal);
if(A4_Meal==1 ){
printf("Sorry, this service is not available for subscription. Thank you.\n");}

//Laundry:
printf("\nDo you want to subscribe for Laundry?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&A4_Laundry);
if(A4_Laundry==1){
Laundry_rate;
printf("How many weeks of subscription?\n");
scanf("%i",&A4_L_week);}
if(A4_Laundry==2){
A4_Laundry=0;}
//Gym
printf("\nDo you want to subscribe for Gym?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&A4_Gym);
if(A4_Gym==1 ){
printf("Sorry, this service is not available for subscription. Thank you\n");}

  printf("\nPlease enter your name:");
  scanf("%s", A4_Name);
  printf("Please enter your Student ID:");
  scanf("%s",A4_SID);
  room_total= A4_room_rate*A4_R_week;
  L_total = Laundry_rate*A4_L_week;
  I_total = A4_Internet_rate*A4_I_week;
  A4_total = room_total + I_total+L_total;

Pay3:
  printf("\n\nHere is your bill.\nWeekly rate for the room\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the laundry\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the Internet: RM%i\n%i weeks of subscription\t\t: RM%i\nTotal amount payable is RM%i.\n",A4_room_rate, A4_R_week, room_total, Laundry_rate,A4_L_week,L_total,A4_Internet_rate,A4_I_week,I_total,A4_total);
  printf("\nDo you want to make payment now or later by cash?\n1 Now\n2 Cash\nPlease enter your option:");
  scanf("%i",&pay);
  if(pay==1){
    printf("\nPlease deposit your money in the slot provided.\nMaximum cash per deposit is 100 pieces of any combined denominations.\n");
    printf("Thank you for your payment.\n\n");
    goto Main_Menu;}
  if(pay==2){
    printf("Please proceed to counter 1. Payment must be made within 7 days. Thank you.\n\n");
    goto Main_Menu;}
  else{
    goto Pay3;}
}

//female+A1
if((GDR==2 && choose==1) || (GDR==2 && choose==2) || (GDR==2 && choose==3)){
printf("\nSorry. This block is not ready for occupancy.");
goto Details;}
//female+B4
if(GDR==2 && choose==4){
B4:
printf("\nHow many weeks of room booking?\n");
scanf("%i",&B4_R_week);

//Internet:
printf("\nDO you want to subscribe for Internet?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&B4_Internet);
if(B4_Internet==1){
B4_Internet_rate;
printf("How many weeks of subscription?\n");
scanf("%i",&B4_I_week);}
if(B4_Internet==2){
B4_Internet=0;}

//Meal:
printf("\nDo you want to subscribe for Meal?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&B4_Meal);
if(B4_Meal==1 ){
printf("Sorry, this service is not available for subscription. Thank you.\n");}

//Laundry:
printf("\nDo you want to subscribe for Laundry?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&B4_Laundry);
if(B4_Laundry==1){
Laundry_rate;
printf("How many weeks of subscription?\n");
scanf("%i",&B4_L_week);}
if(B4_Laundry==2){
B4_Laundry=0;}
//Gym
printf("\nDo you want to subscribe for Gym?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&B4_Gym);
if(B4_Gym==1 ){
printf("Sorry, this service is not available for subscription. Thank you\n");}

  printf("\nPlease enter your name:");
  scanf("%s", B4_Name);
  printf("Please enter your Student ID:");
  scanf("%s",B4_SID);
  room_total= B4_room_rate*B4_R_week;
  L_total = Laundry_rate*B4_L_week;
  I_total = B4_Internet_rate*B4_I_week;
  B4_total = room_total + I_total+L_total;

Pay4:
  printf("\n\nHere is your bill.\nWeekly rate for the room\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the laundry\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the Internet: RM%i\n%i weeks of subscription\t\t: RM%i\nTotal amount payable is RM%i.\n",B4_room_rate, B4_R_week, room_total, Laundry_rate,B4_L_week,L_total,B4_Internet_rate,B4_I_week,I_total,B4_total);
  printf("\nDo you want to make payment now or later by cash?\n1 Now\n2 Cash\nPlease enter your option:");
  scanf("%i",&pay);
  if(pay==1){
    printf("\nPlease deposit your money in the slot provided.\nMaximum cash per deposit is 100 pieces of any combined denominations.\n");
    printf("Thank you for your payment.\n\n");
    goto Main_Menu;}
  if(pay==2){
    printf("Please proceed to counter 1. Payment must be made within 7 days. Thank you.\n\n");
    goto Main_Menu;}
  else{
    goto Pay4;}}

if((GDR==1 && choose==5) || (GDR==2 && choose==5)){
  goto Main_Menu;}

else{
  goto Main_Menu;}

if(menu==2){
printf("\n1 Check by type\n2 Check by gender\n3 Main Menu\nPlease enter your option:");
scanf("%i",&check);
if(check==1){
Room_Type();
scanf("%i",&choose);}
}
}