Hi Guys

This has been going on for a while but now I have finally decided to do something about it.

A few weeks ago I compiled a small C program from a book I was reading.
It compiled fine but I wanted to make a slight change to the code and instead of compiling the new code and calling it a different name I tried to delete the original exe (calculator.exe) so I could simply make a new one. But when I try to delete/copy or move the exe "Cannot delete calculator: it is being used by another person or program" I checked my running processes to see if for some strange reason the program was running in the background but nothing and the exe has been sitting on my desktop ever since and its annoying.

Does anyone know what I can do to remove this annoying exe please and does anyone know why this has happened.


Many thanks

HLA91

P.S here is the code

#include <stdio.h>

char line[100];/* Line of text from input*/
int result; /* This shpws the current result of calculation*/
char operator;/*Operator teh user specified*/
int value;/* Value specified after the operator*/
char enter; 

int main ()
{
    printf("H Calculator, for help/license press h, to quit press q\n");
    printf("\n");
    result = 0;
    /* loop forever or until break reached*/
    while (1) {
          printf("\n");
          printf("Enter calculation: \n");
          printf("\n");
          printf("Result: %d\n", result);
          printf(" \n ");
          
          fgets(line, sizeof(line), stdin);
          sscanf(line, "%c %d", &operator, &value);
          
          if((operator == 'q') || (operator == 'Q'))
          break;
          
          switch (operator) {
          
          case '+':
                       result += value;
                       break;
                       case '-': 
                              result -= value;
                              break;
                               case '*':
                              result *= value;
                              break;
                              case 'h':
                                     printf("\tH Calculator\n");
                                     printf("V 1.1\n");
                                     printf("Written by Harry Angell, to use calc simply\n");
                                     printf("Enter the operator followed by the number,eg: +5\n");
                                     printf("\n");
                                     printf("Press return");
                                     
                                     fgets(line, sizeof(line), stdin);
                                     sscanf(line, "%c" , &enter);
                                                                                
    
                                     printf("\n");
                                     printf("\n");
                                     break;
                              case '/':
                              if (value == 0) {
                                        printf("Error: Divide by zero\n");
                                        printf("   operation ignored\n");
                                        } else
                                          result /= value;
                                          break;
                                           default:
                                                 printf("Unknown operator %c\n", operator);
                                                 break;
                                          }
                                        }
                              return (0);
}

I've seen similar problems with Windows XP and earlier versions, and the only way I could resolve the problem was to reboot the computer. I'm using Vista Home now and have not had that problem with this version of Windows.

Get process explorer from www.sysinternals.com. One of the many useful features it has is a search tool to find out who's using a file.
It would be the first step to finding out a real answer than just "*shrug* reboot"

Dev-C++ uses MinGW.

And AD only said he has seen the problem, not that he tried compiling OPs code.

The problem likely stems from the 16-bit executable trying to do something in a way that XP doesn't like. It is picky about stuff like that. I've re-written old programs to compile with a modern compiler just so they would run properly.

What it sounds like is that the program is not terminating properly, and the DOS emulator (that comes with Windows to run 16-bit applications) is snagging it in memory because of that.

I could be totally wrong. Let me give it a compile and see what happens...

[EDIT] It behaves properly for me on XP using GCC 4.x.

Another hint: check if an antivirus program is running on the computer. If it is, turn it off to see if that fixes the problem. I've seen Norton Antivirus have some problems with some valid programs. Turned off Norton and the problems went away. Of course you want to turn it back on before accessing the web.

I am using Dev C++ and this has never happened before, only with that specific code. I got rid of it by going into safe mode, I dont have norton, I use avast and comodo pro firewall. Thanks for help guys I know what to do next time IF this ever happens again

This question has already been answered. Start a new discussion instead.