Question: Please help me with debug mode. I'm really confused; my code is working I just need to somehow incorporate debug mode on my codes. Here

Please help me with debug mode. I'm really confused; my code is working I just need to somehow incorporate debug mode on my codes.

Here suppose to be the instruction:

  • Your program must use command-line arguments for debugging.

  • This program may be invoked by typing the executable name (./homework3) or with the option debug. (./homework3 debug). Anything else such as ./homework3 debug test or ./homework3 test should give an error message AND EXIT.

  • To check the given argument, use at least one function declared in string.h.

  • When the program runs in the debug option, it must print additional information on the screen.

    • The debug output must verify the following items

      • the name of the called function
      • The parameter names and values passed to the function (but you don't have to print variables of struct record * and struct record **)
    • Every non-main function definition, including the stubs, must have the debug output described above, when the debug option is invoked.

    • The output must be meaningful and distinguishable from the regular output.

      At least, you should add a blank line between the regular and debug outputs.

  • A global variable, debugmode, must be used to indicate whether the program is running in the debug mode or not.

Here is my code user_interface.c which needs debug mode

#include

#include"record.h"

#include"database.h"

void getaddress (char s[], int a){}

void menu()

{

printf(" Greetings, what do you want to do with the database? ");

printf("------------------------------------------------------------------------ ");

printf(" 1. add ");

printf(" 2. printall ");

printf(" 3. find ");

printf(" 4. delete ");

printf(" 5. quit ");

}

int main(int argc, char *argv[])

{

struct record * start = NULL;

int tempaccNum;

int accNum = 0;

char name[25];

char inputAddress[50];

int menus;

do {

menu();

printf("Enter your choice: ");

scanf("%d", &menus);

printf(" ");

/* Accepts data for new customer */

if (menus == 1) {

printf(" Enter account number: ");

scanf("%d", &accNum);

printf(" Enter name: ");

scanf("%s", name); printf(" Enter mailing address( press ';' to end input): ");

scanf("%[^;]%*c", inputAddress);

getaddress(start->address, accNum);

} /* printing records in the database */

else if (menus == 2) {

printAllRecords(start);

} /* Accepts account number to search */

else if (menus == 3) {

printf(" Enter account number to search: ");

scanf("%d", &tempaccNum);

findRecord(start, tempaccNum);

} /* Accepts account number to delete */

else if (menus == 4) {

printf("Enter account number to delete: ");

scanf("%d", &tempaccNum);

deleteRecord(&start, tempaccNum);

} /* quit the program */

} while (menus != 5);

return 0;

}

Here is record.c (this a stub so it doesn't have anything but it also needs debugmode) also use extern debugmode here as debugmode will be on the user_interface where main function is.

#include

struct record

int addRecord (struct record **, int, char [ ],char [ ]) {

return 0;

}

void printAllRecords(struct record *) {

}

int findRecord (struct record *, int) {

return 0;

}

int deleteRecord(struct record **, int)

{

return 0;

}

Please try your best to help me thanks!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!