By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,219 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

getting an exe. has stopped working when my code runs, what does this mean

P: 1
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.             char *name;
  6.             float bal,stbal,deposits[50],withdrawals[50];
  7.             int nw,nd,i;
  8.  
  9.         printf("Welcome to the Sinclair Banking System.");  /* Introduction to program*/;
  10.         printf("\n\nPlease enter your first name: ");  /* User will be prompted to enter name*/;
  11.         scanf("%s",name);
  12.         fflush(stdin);
  13.  
  14.         printf("\nHello %s",name);  
  15.         printf("\nNow enter your balance in dollors and cents: ");  /* User will be prompted to enter a monetary amount.*/
  16.         scanf("%f",&bal);
  17.         fflush(stdin);
  18.  
  19.         while(bal<0)
  20. {
  21.         printf("\nBalance amount should be greater than zero");  /* If user enters 0 message will appear prompting to try again.*/
  22.         printf("\nenter your balance in dollors and cents:");     /* User prompted again to re-enter. */
  23.         scanf("%f",&bal);
  24.         fflush(stdin);
  25.  
  26. }
  27.         stbal=bal;
  28.         printf("\nEnter number of withdrawls: ");  /* User will be prompted to enter up to 5 withdrawals.*/
  29.         scanf("%d",&nw);
  30.         fflush(stdin);
  31.  
  32.         printf("\nEnter number of deposits: ");  /* User will be prompted to enter up to 5 deposits. */
  33.         scanf("%d",&nd);
  34.         fflush(stdin);
  35.  
  36.         for(i=0;i<nd;i++)
  37. {
  38.         printf("Enter the amount of deposit#%d: ",i+1);  /* User prompt to enter monetary amount of deposit. */
  39.         scanf("%f",&deposits[i]);
  40.         fflush(stdin);
  41.  
  42.         while(deposits[i]<0)
  43. {
  44.         printf("\nDeposit amount should be greater than zero");  /* If user enters 0, user will be re-prompted to enter again.*/
  45.         printf("\nEnter the amount of deposit#%d: ",i+1);
  46.         scanf("%f",&deposits[i]);
  47.         fflush(stdin);
  48. }
  49.             bal=bal+deposits[i];
  50. }
  51.             printf("\n");
  52.             for(i=0;i<nw;i++)
  53. {
  54.             printf("Enter the amount of withdrawl#%d: ",i+1);  /* User prompt to enter monetary amount of withdrawal.*/
  55.             scanf("%f",&withdrawals[i]);
  56.             fflush(stdin);
  57.  
  58.             while(withdrawals[i]>bal)
  59. {
  60.             printf("\n***withdrawl amount exceeds the current balance.***");  /* If user enters amount greater than the balance, error message will appear. */
  61.             printf("\nEnter the lower amount of withdrawl#%d: ",i+1);  /* User is prompted to re-enter amount. */
  62.             scanf("%f",&withdrawals[i]);
  63.             fflush(stdin);
  64. }
  65.             bal=bal-withdrawals[i];
  66.             if(bal==0)
  67. {
  68.             printf("\nyour balance is zero");  /* Balance of 0 is stated and no more withdrawals can be made. */
  69.             printf("\n***No more withdrawals should be made.***");
  70.             exit(0);
  71. }
  72. }
  73.  
  74.         printf("\n***The Closing balance %s is $%.2f ***\n",name,bal);  /* Based of the amount left in the bank, the appropiate message will appear. */
  75.         if(bal>=50000.00)
  76.         printf("\n*** %s it is time to invest some money!***\n",name);  
  77.         else if(bal>=15000.00 && bal<=49999.99)
  78.         printf("\n*** %s may be you should consider a CD!***\n",name);
  79.         else if(bal>=1000.00 && bal<=14999.99)
  80.         printf("\n*** %s keep up the good work!***\n",name);
  81.         else
  82.         printf("\n*** %s your balance is getting low!***\n",name);
  83.  
  84.             printf("\n***Bank Record***\n");
  85.             printf("Starting Balance:$%.2f\n",stbal);
  86.  
  87.             for(i=0;i<nd;i++)
  88.             printf("Deposit #%d: %.2f\n",i+1,deposits[i]);
  89.             printf("\n");
  90.             for(i=0;i<nw;i++)
  91.             printf("Withdrawal #%d: %.2f\n",i+1,withdrawals[i]);
  92.             printf("\n");
  93.             printf("\nEnding Balance: $%.2f",bal);
  94.             return 0;
  95. }
Apr 10 '11 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
Do you mean that a) you create an exe and then b) run the exe abd then c) try to recreate the exe and it fails here?

If so, you may need to be sure the execution window for the original exe has been closed. Otherwise your build fails trying to write to a file that's in use.

If this is not your probem, please provide more information.
Apr 11 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.