Error msg:Permission denied, Id returned 1 exit status??

Error msg:Permission denied, Id returned 1 exit status??

Post by alexphang88 on Sun Jan 16, 2011 3:03 pm
([msg=52248]see Error msg:Permission denied, Id returned 1 exit status??[/msg])

I'm quite confused by the error msg mentioned in the topic title, I get is most of the time even when my code is correct [P.S: I might be wrong >.> since I've only been studying it for 4 days, I only got to the IF statement]

Code: Select all
#include <stdio.h>

int main()
{
  int num;

  printf("Please enter a number: ");
 
  scanf("%d", &num); /*You pressed enter here . . .*/
 
  if(0<num, num<5){/* || means or, 0<num<5 is the same as 0<num || num<5 ?*/
                  printf("You entered %d, this number is between 0 and 5.", num);
                 }
  else if(num>5, num<100){
                          printf("You entered %d, this number is larger than 5 but smaller than 100", num);
                      }
  else {
        printf("The number is larger than 100.");
      }
           
  getchar(); /*So you must place a getchar(); here to cancel it out?*/
  getchar();
 
}
This is the one that I wrote originally. (I'm using DEV C++) Yet when I compile and run it it displays the error msg:"Permission denied, Id returned 1 exit status".

Then I tried to change the layout a bit so that it looked like this
Code: Select all
#include <stdio.h>

int main()
{
  int num;

  printf("Please enter a number: ");
 
  scanf("%d", &num); /*You pressed enter here . . .*/
 
  if(0<num, num<5){/* || means or, 0<num<5 is the same as 0<num || num<5 ?*/
  printf("You entered %d, this number is between 0 and 5.", num);
  }
  else if(num>5, num<100){
  printf("You entered %d, this number is larger than 5 but smaller than 100", num);
  }
  else {
  printf("The number is larger than 100.");
  }
           
  getchar(); /*So you must place a getchar(); here to cancel it out?*/
  getchar();
 
}
And then the code worked fine?! O.o
and then I tried (by coincidence) to only pull the last most curly bracket up one line, and it worked!?

Code: Select all
#include <stdio.h>

int main()
{
  int num;

  printf("Please enter a number: ");
 
  scanf("%d", &num); /*You pressed enter here . . .*/
 
  if(0<num, num<5){/* || means or, 0<num<5 is the same as 0<num || num<5 ?*/
                  printf("You entered %d, this number is between 0 and 5.", num);
                 }
  else if(num>5, num<100){
                          printf("You entered %d, this number is larger than 5 but smaller than 100", num);
                      }
  else {
        printf("The number is larger than 100.");
      }
           
  getchar(); /*So you must place a getchar(); here to cancel it out?*/
  getchar();
}


I tend to get this msg a lot when I got my codes correct sometimes, what is causing this? Or is the problem really lie in the code I use? Thanks in advance for any help, have a nice day.
alexphang88
New User
New User
 
Posts: 7
Joined: Mon Jan 04, 2010 11:09 am
Blog: View Blog (0)


Re: Error msg:Permission denied, Id returned 1 exit status??

Post by dellex on Sun Jan 16, 2011 4:37 pm
([msg=52253]see Re: Error msg:Permission denied, Id returned 1 exit status??[/msg])

No, the problem is not the code.

I'm assuming you're using windows.
(If you were using linux, it could be a problem with permissions.)

The most possible explanation is that your program is already running when you try to re-build it (actually re-link it, as 'ld' refers to the linker). Make sure that every time you run the program, it exits normally.... btw, what's the deal with the double "getchar()"?


alexphang88 wrote:
Code: Select all
/* || means or, 0<num<5 is the same as 0<num || num<5 ?*/

yes, "||" means "OR", but "0<num<5" is translated to "0<num && num<5" where "&&" is the "AND" operator.
User avatar
dellex
New User
New User
 
Posts: 34
Joined: Tue Jun 01, 2010 7:36 am
Blog: View Blog (0)


Re: Error msg:Permission denied, Id returned 1 exit status??

Post by fashizzlepop on Sun Jan 16, 2011 5:34 pm
([msg=52254]see Re: Error msg:Permission denied, Id returned 1 exit status??[/msg])

alexphang88 wrote:
Code: Select all
/* || means or, 0<num<5 is the same as 0<num || num<5 ?*/



False. You mean && not ||. "0<num || num<5" will accept any number as 16 is greater than 0 or -20 is less than 5.
The glass is neither half-full nor half-empty; it's merely twice as big as it needs to be.
User avatar
fashizzlepop
Developer
Developer
 
Posts: 2304
Joined: Sat May 24, 2008 1:20 pm
Blog: View Blog (0)


Re: Error msg:Permission denied, Id returned 1 exit status??

Post by alexphang88 on Mon Jan 17, 2011 9:15 am
([msg=52294]see Re: Error msg:Permission denied, Id returned 1 exit status??[/msg])

I see, so basically I need to run the task manager to check if my stuff is running, then compile and run again?

Btw, I always see this return 0; thing appearing at the end of each code in the tutorial, although it said it is to return a 0 back to the console so that it knows the program ran successfully, but without it the program still works?!(some tutorial's code doesn't include it) and also, isn't returning a 0 means FALSE?
alexphang88
New User
New User
 
Posts: 7
Joined: Mon Jan 04, 2010 11:09 am
Blog: View Blog (0)


Re: Error msg:Permission denied, Id returned 1 exit status??

Post by neuromanta on Mon Jan 17, 2011 10:44 am
([msg=52302]see Re: Error msg:Permission denied, Id returned 1 exit status??[/msg])

alexphang88 wrote:I see, so basically I need to run the task manager to check if my stuff is running, then compile and run again?

Btw, I always see this return 0; thing appearing at the end of each code in the tutorial, although it said it is to return a 0 back to the console so that it knows the program ran successfully, but without it the program still works?!(some tutorial's code doesn't include it) and also, isn't returning a 0 means FALSE?


Returning a 0 at the end of the program (provided that there were no error) is a Unix convention. When you write programs for Linux, you should follow this convention (that's why the main() function must return an int, not void). It helps your program to report back to the operating system (if you return a number other than 0, it means some kind of error).
False meaning 0 and True meaning 1 is just another convention (some people doesn't agree with it btw, me included).
User avatar
neuromanta
Poster
Poster
 
Posts: 303
Joined: Mon Nov 30, 2009 9:29 am
Location: Hungary
Blog: View Blog (0)


Re: Error msg:Permission denied, Id returned 1 exit status??

Post by apples on Tue Jan 25, 2011 4:47 pm
([msg=52872]see Re: Error msg:Permission denied, Id returned 1 exit status??[/msg])

neuromanta wrote:Returning a 0 at the end of the program (provided that there were no error) is a Unix convention


No, it is a C convention. Returning 0 upon success is a valid course of action for any conforming C implementation.
User avatar
apples
New User
New User
 
Posts: 37
Joined: Sat Apr 12, 2008 8:30 pm
Blog: View Blog (0)


Re: Error msg:Permission denied, Id returned 1 exit status??

Post by neuromanta on Fri Jan 28, 2011 6:19 am
([msg=52962]see Re: Error msg:Permission denied, Id returned 1 exit status??[/msg])

apples wrote:
neuromanta wrote:Returning a 0 at the end of the program (provided that there were no error) is a Unix convention


No, it is a C convention. Returning 0 upon success is a valid course of action for any conforming C implementation.


We both are right, yet neither of us are. Unix and C was developed parallel to each other, in fact, C was created for Unix. So it's hard to tell in which one this convention was first. But it's a convention in both of them (do you think that you shouldn't return 0 in a Unix-like environment if the program is written in another language?).
User avatar
neuromanta
Poster
Poster
 
Posts: 303
Joined: Mon Nov 30, 2009 9:29 am
Location: Hungary
Blog: View Blog (0)



Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests

cron