[c] C compile error: Id returned 1 exit status

For some reason, when I try compiling a program, the compiler says permission denied and Id returned 1 exit status. Could anyone tell me what that means? Thank you

#include <stdio.h>                                               /* Library inclusions */
#include "genlib.h" 
#include "simpio.h"

int binSearch(int val, int numbers[], int size1);                /* prototypes */
void sortArray (int numbers[], int size1);                       
int indexMax (int numbers[], int low, int high);
void swap (int numbers[], int loc, int loc1);
void getArray (int numbers[], int size1);
void displayArray (int numbers[], int size1);

main()
{
  int value, size1;

  printf("Enter the number of elements: ");
  size1=GetInteger(); 
  int numbers[size1];
  getArray(numbers, size1); 
  sortArray(numbers, size1); 
  displayArray(numbers, size1);
  printf("\nEnter value to find: ");
  value=GetInteger();
  binSearch(value, numbers, size1);
  getchar();
}

void sortArray (int numbers[], int size1)                        /*Function sortArray*/
{
 int i , maxInd;

 for (i= size1-1; i>=0;i--)
 {
     maxInd=indexMax(numbers, 0, i);
     swap (numbers, i, maxInd);
 }
}

void displayArray (int numbers[], int size1)                     /*Function displayArray*/
{
 int i;

 printf("This is the sorted set of numbers: \n");
 for (i=0; i< size1; i++)
 {
         printf ("%d\t", numbers[i]); 
     }
}

void getArray (int numbers[], int size1)                         /*Function getArray*/
{
 int i;

 for (i=0; i<size1; i++)
 {
     printf ("Enter the values of the %d elements: ", size1);
     numbers[i]=GetInteger();
 }
}

int indexMax (int numbers[], int low, int high)                  /*Function indexMax*/
{
int i, maxInd;

maxInd=high;
for (i=low;i<=high;i++)
{
    if (numbers[i]>numbers[maxInd]) 
    {
                   maxInd =i;
    }
    }
    return (maxInd);
}

void swap (int numbers[], int loc, int loc1)                     /*Function swap*/
{
 int temp;

 temp=numbers[loc];
 numbers[loc]=numbers[loc1];
 numbers[loc1]=temp;
}

int binSearch(int val, int numbers[], int size1)                 /*Function binSearch*/
{
 int low, high, mid;

 low=0;
 high=size1-1;
 while(low<=high)
 {
                 mid=(low+high)/2;
                 if(val<numbers[mid])
                 {
                                 high=mid-1;                
                 }            
                 else if(val>numbers[mid])
                 {
                                 low=mid+1; 
                 }   
                 else if(val==numbers[mid])
                 {
                                 printf("Your number is in location %d\n", mid+1);break;    
                 } 
                 else
                 {
                                 printf("Your value is not in the array.");        
                 }
   }
}

The above is the binary search algorithm code I tried to compile.

This question is related to c compiler-errors permission-denied

The answer is


Just try " gcc filename.c -lm" while compiling the program ...it worked for me


You may compiling your program while another program may be running in background. Firstly, see if another program is running .Close it and then try ro compile.


it seems as if it comes when u have an previous compiled version of your program running


Is a simple MAYUS word. verify the log.


it could be that you just said main{....I use int main{ when I start my main.


My solution is to try to open another file that you can successfully run that you do at another PC, open that file and run it, after that copy that file and make a new file. Try to run it.


1d returned 1 exit status error

First of all you have to create a project by clicking file new and then project and give project name select the language c or c++ and select empty also. Then your program is under that project... And then give a program name save it.... Ensure that your under some project to compile and run a program...


This answer is written for C++ developers, because I was haunted by such problem as one. Here is the solution:

Instead of

main()
{

}

please type

int main()
{

}

so the main function can be executed.

By the way, 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 exist status"

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


I bet for sure, that this is because you didn't close the running instance of the program before trying to re-compile it.

Generally, ld.exe returns 1 when it can't access required files. This usually includes

  • Can't find the object file to be linked (or Access denied)
  • Can't find one or more symbols to link
  • Can't open the executable for writing (or AD)

The program looks completely fine, so the second point should not hit. In usual cases, it's impossible for ld to fail to open the object file (unless you have a faulty drive and a dirty filesystem), so the first point is also nearly impossible.

Now we get to the third point. Note that Windows not allow writing to a file when it's in use, so the running instance of your program prevents ld.exe from writing the new linked program to it.

So next time be sure to close running programs before compiling.


Using code::blocks , I have solved this error by doing :

workspace properties > build target > build target files

and checking every project file.


Examples related to c

conflicting types for 'outchar' Can't compile C program on a Mac after upgrade to Mojave Program to find largest and second largest number in array Prime numbers between 1 to 100 in C Programming Language In c, in bool, true == 1 and false == 0? How I can print to stderr in C? Visual Studio Code includePath "error: assignment to expression with array type error" when I assign a struct field (C) Compiling an application for use in highly radioactive environments How can you print multiple variables inside a string using printf?

Examples related to compiler-errors

intellij idea - Error: java: invalid source release 1.9 Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug' Deserialize JSON with Jackson into Polymorphic Types - A Complete Example is giving me a compile error Android java.exe finished with non-zero exit value 1 error: expected primary-expression before ')' token (C) What does "collect2: error: ld returned 1 exit status" mean? Python3: ImportError: No module named '_ctypes' when using Value from module multiprocessing Maven error :Perhaps you are running on a JRE rather than a JDK? What does a "Cannot find symbol" or "Cannot resolve symbol" error mean? Operator overloading ==, !=, Equals

Examples related to permission-denied

Error: EACCES: permission denied, access '/usr/local/lib/node_modules' PermissionError: [Errno 13] Permission denied Github permission denied: ssh add agent has no identities WinSCP: Permission denied. Error code: 3 Error message from server: Permission denied Permission denied on accessing host directory in Docker .bashrc: Permission denied C compile error: Id returned 1 exit status Executing a shell script from a PHP script Permission denied on CopyFile in VBS Node.js EACCES error when listening on most ports