Thread: Having trouble with my compiler

  1. #1
    Unregistered
    Guest

    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);
    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    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.

  3. #3

    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

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    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
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiler Paths...
    By Cobra in forum C++ Programming
    Replies: 5
    Last Post: 09-26-2006, 04:04 AM
  2. C Compiler and stuff
    By pal1ndr0me in forum C Programming
    Replies: 10
    Last Post: 07-21-2006, 11:07 AM
  3. I can't get this new compiler to work.
    By Loduwijk in forum C++ Programming
    Replies: 7
    Last Post: 03-29-2006, 06:42 AM
  4. how to call a compiler?
    By castlelight in forum C Programming
    Replies: 3
    Last Post: 11-22-2005, 11:28 AM
  5. help with compiler trouble. Cout verification?
    By bigd5 in forum C++ Programming
    Replies: 6
    Last Post: 05-31-2005, 07:22 PM