Error in C
SofhinWong1 (3)

#include <stdio.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:");
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
mwilki7 (282)

I'll try to annotate my code

// my input array
char choice[100];

// get first input
scanf("%s", choice);

// if my input "choice" is the same as the word "done" then I am finished
int finished = strcmp(choice, "done");

// while loop: keep looping until 'finished' is 0
// very similar to a for loop
// if 'finished' is 0 then we will not enter the while loop
while (finished != 0)
    // read a new word
    scanf("%s", choice);

    // check to see if I wrote "done"
    finished = strcmp(choice, "done");