# Having trouble with my compiler

• 10-25-2001
Unregistered
Having trouble with my compiler
My compiler acts up sometimes can somebody run this. I might have some major problems too but I don't see any. Please let me know what the hell is going on with this thing.

// This is a late charge calculator

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

#define year 365
#define month 30

void main(void)
{
char year1[3],month1[1],day1[1],year2[3],month2[1],day2[1];
int outstand,inteyear,intemonth,inteday,inteyear2,inte month2,inteday2;
int balyear,balmonth,balday;
int peryear,permonth,perday,totaldays,interestowing,to tal;

printf("\n Enter the Date Today(year,month,date):");
scanf("%s %s %s",year1,month1,day1);
inteyear=atoi(year1);
intemonth=atoi(month1);
inteday=atoi(day1);

printf("\n Enter the date it was due(year,month,date):");
scanf("%s %s %s",year2,month2,day2);
inteyear2=atoi(year2);
intemonth2=atoi(month2);
inteday2=atoi(day2);

if(inteyear<inteyear2)
{
printf("\nPlease ensure that the year and date are correct");
}
else
printf("\n Please Enter the outstanding balance:");
scanf("%d",outstand);

balyear=inteyear-inteyear2;
balmonth=intemonth-intemonth2;
balday=inteday-inteday;

totaldays=(balyear*year)+(balmonth*month)+(balday) ;

interestowing=totaldays*.12; //12 percent interest

total=outstand+interestowing;

printf("\nThe total late charge is: %d",interestowing);
printf("\nThe New Total is: %d", total);
}
• 10-25-2001
quzah
I refuse to run potentially hazardous code. Your code has such potential. Here is why:

> void main(void)

This is undeniably wrong. Never ever do this again.

int main(void)

Quzah.
• 10-26-2001
unanimous
works for me
here is the code: the only problem I had was that the variables were split on the line i fixed that because it had a parsar error:

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

#define year 365
#define month 30

void main(void)
{
char year1[3],month1[1],day1[1],year2[3],month2[1],day2
[1];
int outstand,inteyear,intemonth,inteday,inteyear2,inte month2,inteday2;
int balyear,balmonth,balday;
int peryear,permonth,perday,totaldays,interestowing,to tal;

printf("\n Enter the Date Today(year,month,date):");
scanf("%s %s %s",year1,month1,day1);
inteyear=atoi(year1);
intemonth=atoi(month1);
inteday=atoi(day1);

printf("\n Enter the date it was due(year,month,date):");
scanf("%s %s %s",year2,month2,day2);
inteyear2=atoi(year2);
intemonth2=atoi(month2);
inteday2=atoi(day2);

if(inteyear<inteyear2)
{
printf("\nPlease ensure that the year and date are correct");
}
else
printf("\n Please Enter the outstanding balance:");
scanf("%d",outstand);

balyear=inteyear-inteyear2;
balmonth=intemonth-intemonth2;
balday=inteday-inteday;

totaldays=(balyear*year)+(balmonth*month)+(balday)
;

interestowing=totaldays*.12; //12 percent interest

total=outstand+interestowing;

printf("\nThe total late charge is: %d",interestowing);
printf("\nThe New Total is: %d", total);
}

[B]YOU MIGHT WANT TO TRY USING BLOODSHED'S DEV C++ IT IS WHAT I USED: www.bloodshed.net
• 10-26-2001
Sebastiani
You got answers, but ignored them!

Compile This, and note the changes.

And Study a book on C!

Code:

```#include <string.h> #include <ctype.h> #include <stdlib.h> #include <conio.c> #define YEAR 365 #define MONTH 30   int main()  { char  cyear[20], cmonth[20], cday[20];   float  outstand, year1, month1, day1, year2, month2, day2, balyear, balmonth, balday, totaldays, interestowing, total; ///float  peryear,permonth,perday;    // <---Never Used! do{ clrscr();  // <-- Defined in conio.c printf("\n Enter the Date Today(year,month,day): \n\n\n"); scanf("%s %s %s",cyear,cmonth,cday);  // or:  scanf("%s %s %s",&cyear[0], &cmonth[0], &cday[0]);   year1  = atoi(cyear); month1 = atoi(cmonth); day1  = atoi(cday);   printf("\n Enter the date it was due(year,month,day):\n\n\n"); scanf("%s %s %s",cyear,cmonth,cday);  // <--------------Reuse your strings! year2  = atoi(cyear); month2 = atoi(cmonth); day2  = atoi(cday); if(year1 < year2) { printf("\n The Due Date Is Later Than Today's Date! You Must Start Over!\n\n "); continue;  // <--- Goes back to beginning of "do/while" loop... }   else   printf("\n Please Enter the outstanding balance:"); scanf("%f",&outstand);  //<-- Must use "&"!!   balyear      = year1 - year2;   balmonth      = month1 - month2;   balday        = day1 - day2; totaldays    = (balyear * YEAR) + (balmonth * MONTH) + (balday);   interestowing = totaldays * 0.12; //12 percent interest (PER DAY!... Are you sure?) total        = outstand + (outstand * interestowing); printf("\nThe total late charge is: %.2f",interestowing); printf("\nThe New Total is: %.2f", total); printf("Press 1 To Do This Again, 0 To Exit...\n\n\n"); int choice; scanf("%i", &choice); }while(choice);  // <---Same as "}while(choice == 1);"   }    //<---The End```