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

int strcmp(const char *s1, const char *s2);
void overdue();

int main(){
overdue();
}

void overdue(){
int x,overdue_fees;
char answ[10];
char yes [10] = "yes";
char no[10] = "no"; 
int ret = strcmp(yes, no);

     
system ("cls"); 
printf("\n <<<<<<<<<<<<<<<<<<<<<<<<**********OVERDUE ITEMS*********<<<<<<<<<<<<<<<<<<<<<<<<<< \n");
printf("\n");
printf("PLEASE ENTER BARCODE OF OVERDUE ITEM:\n ignore me!\n");
//search for barcode in active book loans and info on that loan

printf("Is it past the return date?\n");
fgets(answ,10,stdin);
printf(answ);
getchar();
if (strcmpi(answ,yes)==0){
                printf("By how many days?");
                getchar();
                scanf("%d",&x);
                getchar();
                while (x!=0){
                       overdue_fees=1*1;
                       printf("%d $",overdue_fees);
                       x++;
                       }
}
}

WHAT AM I DOING WRONG? IT KEEPS CUTTING OFF ATFER I ENTER YES AS THE STRING TO BE STORED IN ANSW. I'M NEW HERE SO IF I'M NOT FOLLOWING PROTOCOL PLEASE EXCUSE ME BUT I NEED HELP NOW!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Recommended Answers

All 2 Replies

Firstly, presentation is paramount. Please wrap your code in code tags. Use the edit button to edit your post.

[code]

/*code goes here */

[/code]

You may be frantic but there's no need to panic, this is a solvable problem.
I haven't run your program yet but there are a few issues.

Why are you using your own prototype for strcmp at the top? There should already be one in string.h. Also, when you call it you have strcmpi. There's a such thing as stricmp (for case insensitive comparisons) but it's not standard.

Also, you presumably pad your yes and no strings with extra spaces so they are guaranteed not to match up with whatever you enter. char yes[] = "yes" will do.

What is the value of x when you enter your while loop?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.