Question

int NameExist(queue **wait, char *name) { queue *Restaurant = *wait; while( Restaurant == NULL) { switch(Restaurant)...

int NameExist(queue **wait, char *name)

{

queue *Restaurant = *wait;

while( Restaurant == NULL) {

switch(Restaurant)

{

  case 1: return 0;

          break;

  case 2: (strcmp(Restaurant->name, name)==0);

          return 1;

         Restaurant = Restaurant->Next;

          break;

}

return 0;

}

}

I get this error for this function -error: switch quantity not an integer
switch(Restaurant)
^~~~~~~~~~

boolean update(queue **wait, char* name)

{

    queue *Restaurant = *wait;

    // if there is no order yet

    while(Restaurant == NULL) {

        return FALSE;

    }

    

    while(Restaurant != NULL) {

        switch (strcmp(Restaurant->name, name) == 0) {

            case 1: if(Restaurant->Status == Time) {

                return FALSE;

                break;

            }

          case 2: Restaurant->Status = Time;

                if(debugMode == TRUE) {

                    printf("DebuggingMode \n");

                    displayListInformation(wait);

                    

                }

                return TRUE;

            }

        }

}

I get getting a warning message for this function.  warning: switch condition has boolean value [-Wswitch-bool]
switch (strcmp(Restaurant->name, name) == 0) {
^~~~~~

void displayList(queue **wait)

{

        queue *Restaurant = *wait;

while(Restaurant != NULL) {

    

    switch(Restaurant->Status == Time) {

        case 1:  printf("Wait \n");

            break;

                case 2: printf("Calling ahead\n");

                Restaurant = Restaurant->Next;

        }   

         return;

        }            

}

also get the same warning for this function-  warning: switch condition has boolean value [-Wswitch-bool]
switch(Restaurant->Status == Time) {
^~~~~~

Please help I'm not sure if I can write these another way to fix them. any help will be highly appreciated.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PLEASE GIVE IT A THUMBS UP

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

int NameExist(queue **wait, char *name)

{
queue *Restaurant = *wait;
while (Restaurant == NULL)
{
switch ((int)Restaurant)
{
case 1:
return 0;
break;
case 2:
(strcmp(Restaurant->name, name) == 0);
return 1;
Restaurant = Restaurant->Next;
break;
}
return 0;
}
}

// In this the switch statement value is of type 'queue' and in case the case 1,
// where 1 is integer, then in that case just change type of case, as I have done.

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

boolean update(queue **wait, char *name)
{
queue *Restaurant = *wait;
while (Restaurant == NULL)
{
return FALSE;
}

while (Restaurant != NULL)
{
if (strcmp(Restaurant->name, name) == 0)
{
if (Restaurant->Status == Time)
{
return FALSE;
break;
}
}
else{
Restaurant->Status = Time;
if (debugMode == TRUE)
{
printf("DebuggingMode \n");
displayListInformation(wait);
}
return TRUE;
}
}
}

// In this you are using swtich for TRUE and FALSE, and it is advisable to
// use IF-ELSE for boolean, that's why it was giving warning, I have converted switch to if

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

void displayList(queue **wait)
{
queue *Restaurant = *wait;
while (Restaurant != NULL)
{
if (Restaurant->Status == Time)
{
printf("Wait \n");
}
else
{
printf("Calling ahead\n");
Restaurant = Restaurant->Next;
}
return;
}
}

// Here also the same problem was there

------------------------------------------------------------

There is no output, as I wasn't having the whole code.

Add a comment
Know the answer?
Add Answer to:
int NameExist(queue **wait, char *name) { queue *Restaurant = *wait; while( Restaurant == NULL) { switch(Restaurant)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C programm , ´hello i need your help -Given the C program primes.c with the following main method: int main() { int num, res; char buffer[11]; bool finished = false; while (!finished)...

    C programm , ´hello i need your help -Given the C program primes.c with the following main method: int main() { int num, res; char buffer[11]; bool finished = false; while (!finished) { printf("Enter n > 0 or quit\n"); scanf("%10s", buffer); if (strcmp(buffer, "quit") == 0) { finished = true; } else { // Convert input to number and compute n-th prime num = atoi(buffer); if (num > 0) { res = nth_prime(num); printf("Prime #%d is %d\n", num, res); }...

  • // C code // If you modify any of the given code, the return types, or...

    // C code // If you modify any of the given code, the return types, or the parameters, you risk getting compile error. // Yyou are not allowed to modify main (). // You can use string library functions. #include <stdio.h> #include <stdlib.h> #include <string.h> #pragma warning(disable: 4996) // for Visual Studio #define MAX_NAME 30 // global linked list 'list' contains the list of patients struct patientList {    struct patient *patient;    struct patientList *next; } *list = NULL;  ...

  • Finish function to complete code. #include <stdio.h> #include <stdlib.h> #include<string.h> #define Max_Size 20 void push(char S[],...

    Finish function to complete code. #include <stdio.h> #include <stdlib.h> #include<string.h> #define Max_Size 20 void push(char S[], int *p_top, char value); char pop(char S[], int *p_top); void printCurrentStack(char S[], int *p_top); int validation(char infix[], char S[], int *p_top); char *infix2postfix(char infix[], char postfix[], char S[], int *p_top); int precedence(char symbol); int main() { // int choice; int top1=0; //top for S1 stack int top2=0; //top for S2 stack int *p_top1=&top1; int *p_top2=&top2; char infix[]="(2+3)*(4-3)"; //Stores infix string int n=strlen(infix); //length of...

  • In c programming The Consumer Submits processing requests to the producer by supplying a file name, its location and a character. It also outputs the contents of the file provided by the producer...

    In c programming The Consumer Submits processing requests to the producer by supplying a file name, its location and a character. It also outputs the contents of the file provided by the producer to the standard output. The Producer Accepts multiple consumer requests and processes each request by creating the following four threads. The reader thread will read an input file, one line at a time. It will pass each line of input to the character thread through a queue...

  • Edit a C program based on the surface code(which is after the question's instruction.) that will...

    Edit a C program based on the surface code(which is after the question's instruction.) that will implement a customer waiting list that might be used by a restaurant. Use the base code to finish the project. When people want to be seated in the restaurant, they give their name and group size to the host/hostess and then wait until those in front of them have been seated. The program must use a linked list to implement the queue-like data structure....

  • #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(void) { /* Type your code here....

    #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(void) { /* Type your code here. */ int GetNumOfNonWSCharacters(const char usrStr[]) { int length; int i; int count = 0; char c; length=strlen(usrStr); for (i = 0; i < length; i++) { c=usrStr[i]; if ( c!=' ' ) { count++; } }    return count; } int GetNumOfWords(const char usrStr[]) { int counted = 0; // result // state: const char* it = usrStr; int inword = 0; do switch(*it)...

  • // CSE240 Spring 2019 HW 7 & 8 // Write your name here // Write the...

    // CSE240 Spring 2019 HW 7 & 8 // Write your name here // Write the compiler used: Visual studio or gcc // READ BEFORE YOU START: // You are given a partially completed program that creates a linked list of patient information. // The global linked list 'list' is a list of patients with each node being struct 'patientList'. // 'patientList' consists of struct 'patient' which has: patient name, room number, and a linked list of 'doctors'. // The...

  • I need little help with C language. I need to pass what I get from HexToBin(char*...

    I need little help with C language. I need to pass what I get from HexToBin(char* hexdec) into char* input so that what I got there it should pass it as string array parametr. Example: Enter IEEE-Hex: 40200000 Equivalent Binary value is : 01000000001000000000000000000000 Decimal Number: 2.5 #include <stdio.h> void HexToBin(char* hexdec) {    long int i = 0;    while (hexdec[i]) {        switch (hexdec[i]) {        case '0':            printf("0000");            break;...

  • i'm trouble getting my program to print this output and repeat until asked to quit the...

    i'm trouble getting my program to print this output and repeat until asked to quit the program Enter a telephone number using letterss (EXIT to quit): GET LOAN The corresponding telephone number is: 438-5626 Here's my code: #include <stdio.h> #include <string.h> char getNumber(char aC) { char c = ' '; switch (aC) { case 'A': case 'B': case 'C': c = '2'; break; case 'D': case 'E': case 'F': c = '3'; break; case 'G': case 'H': case 'I': c...

  • #include <stdio.h> #include string.h     #define C17_PRICE 12.80 #define F25_PRICE 4.29 #define DN3_PRICE 10.00 #define GG7_PRICE...

    #include <stdio.h> #include string.h     #define C17_PRICE 12.80 #define F25_PRICE 4.29 #define DN3_PRICE 10.00 #define GG7_PRICE 35.00 #define MV4_PRICE 18.49 #define DISCOUNT        0.05 #define DISC_THRES    10 #define SAME_DAY_DELIVERY =   35.0 #define NEXT_DAY_DELIVERY =   20.0    typedef enum{ WRONG, C17, F25, DN3, GG7, MV4} part     /*--- Function Prototypes ------------*/ part getPartType ( void ); int getquantity ( void ); int getDeliveryOption ( void ); float calcPriceOfParts( part orderedPart, int quantity ); float calcTotalCarges ( float orderPrice, char...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT