How do I solve the problem: "Id returned 1 exit status"

#include <stdio.h>#include<conio.h>#include<windows.h>int main(){int P, N, NP=0;printf("Introduzca en nombre del producto:\n");scanf("%f", &N);printf("Introduzca en precio del producto:\n");scanf("%f", &P);if (P <= 1500)NP=P*1.11;else NP=P*1.08;printf("El producto %d cuesta %d", NP, N);getche();return 0;}

The full list of errors is:

Permission deniedId returned 1 exit status
15

Best Answer


It does not have anything to do with code. Your operating system simply does not allow to modify a file while it is in use, so the compilation (actually, linking, ld is the linker) fails, because compiler can't remove the old executable and place a new one. To solve this, simply close all existing processes running that program.

If that won't work, check your permissions for directory the executable is in, or look for any programs that are currently using it (some systems allow programs to place a lock on a file, so no other program can modify it).

Deleting the executable(.exe) file solved the problem. If you are compiling the code multiple times then it may not able to replace the old .exe file.

There's something wrong here:

int N;scanf("%f", &N);

Your data types do not match.

I know the problem is already well solved, but I want to offer another perspective for those who are haunted by the bug message

"[Error] Id returned 1 exit status"

So here it is:

If you compile a C/C++ source file with no main function to execute,there will definitely be a bug message saying:

"[Error] Id returned 1 exit status"

But sometimes we just don't need main function in the file,in such a case, just ignore the bug message.

Alt+F2 in your ide... its sometimes realy helps when you forgeting to close "run" window hah)

This happened to me when i accidently marked my .exe file read only. When i removed it it worked again. (IDK much about programming but this happened to me mayb it helps someone)

if you are compiling in the terminal you need:

sugcc file.c -o nameyouwant./nameyouwant

I'd like to add something to papeho's answer:

If you are using any antivirus software, this may be the reason.Some antivirus might be the fact here, probably for including stdio.h,windows.h or conio.h it predicts that working with such headers may causes attacks on your PC

Probable ways to get rid of it:

1.Try to delete the existing executable file. (Failed because it's being locked on something (maybe antivirus) )

2.Simply rename that file, then rebuild and done (renaming will allow to create another executable file for your code).

3.If failed restarting pc and trying from 1 may fix this.Hope it helps :-)

I was having the same error. And it was a bit difficult to solve because the message says that don't have permission to open the file. But the problem is that the program is still running.

If the program is still running I thought that I will find inside task manager, but wasn't there. So, I tried to delete the file and I wasn't able to delete too. Searching more about I find the program "Process Explorer". With this program I was able to see that my exe file is still running, but with a message saying that the program was suspended. Then I tried to kill through Process Explorer, but without success, because I still don't have permissions. So I close Process Explorer and open with administrator permissions and after all this I was able to kill the process and build and run my file through codeblocks.

I think you should simply change int NP=0; to: float NP=0;

Also change: scanf("%f",&N); and: scanf("%f",&P);to: scanf("%d"&N);and scanf("%d"&P);

And:getche(); to: getch();

I hope this can help you.

#include <iostream>#include <conio.h>#include <string.h>using namespace std;void gotoxy(short x, short y);int main(){FILE *ptrFile= fopen("E:\\ENCD_OUTPUT.html","a");char a[30];cin >> a;cout << a;gotoxy(14, 4);fputs(a, ptrFile);gotoxy(13, 6);fputs(a, ptrFile);getche();}

maybe you forgot to close the terminal window, simply close it and run again.

The following two worked for me:

  • Delete the .exe file and compile again
  • Check if the code is not already running in the terminal (to make sure of this, just close and re-open your IDE/editor)

I am facing the same problem, no matter what, it kept saying the same thing("Permission denied" "Id returned 1 exit status"). I tried many things and this one worked for me.

Go this location [C:\MinGW\mingw32\bin ] and delete the Id.exe file then create new Id.exe file in the same directory.it worked for me.

How to create Id.exe file ??

Just create a empty text document in the above shown directory and type Id.exe as its file name.

NOTE:Double check if you saved the program or not if you are using the vs code. Sometimes it shows error for not saving the program.

Check first that are you using flushall(); or clrscr(); in your program if it is there then for sure you will get that error!!! as it is not allowed in Dev CPP. Use fflush(stdin); instead of it.The problem will be solved surely!!!