6 Replies - 2287 Views - Last Post: 06 July 2010 - 11:28 PM Rate Topic: -----

#1 sawyer686  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-July 10

Fatal error code

Posted 06 July 2010 - 09:24 PM

Im pretty new at programing and recently wrote a program to identify resistor colors.
I wrote, compiled, and ran the program using PellesC. I ran the program once and t wrked with no errors. When I tried to run it again and got

POLINK:fatal error: Access is denied ***error code: 1***.

Does anyone have advice on how to correct this and why it happened? Thanks
Is This A Good Question/Topic? 0
  • +

Replies To: Fatal error code

#2 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5191
  • View blog
  • Posts: 26,897
  • Joined: 10-May 07

Re: Fatal error code

Posted 06 July 2010 - 09:27 PM

View Postsawyer686, on 06 July 2010 - 10:24 PM, said:

how to correct this

Without seeing the code, it's hardly possible to guess how to correct what went wrong.

View Postsawyer686, on 06 July 2010 - 10:24 PM, said:

why it happened?

Because it tried to read or write to a file or directory that it didn't have access to. This is the best guess I can come up with, without seeing the code.
Was This Post Helpful? 0
  • +
  • -

#3 sawyer686  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-July 10

Re: Fatal error code

Posted 06 July 2010 - 09:33 PM

/*******************************************************************************
* Week 4 - Program to find color of resistor                                 
*******************************************************************************/

#include <stdio.h>

void printColor(char digit);

int main(int argc, char *argv[])
{ 
	char digit1;
	char digit2;
	char digit3;
	int validinput = 0;

   do {
	printf("Enter 3 digits>");
	scanf("%c%c%c", &digit1, &digit2, &digit3);
	if ((digit1 >= 48 && digit1 <= 57) &&
		(digit2 >= 48 && digit2 <= 57) &&
		(digit3 >= 48 && digit3 <= 57))   {
		validinput = 1;
	}
	}while (validinput == 0);

	printf("Digit1 is: ");
	printColor (digit1);
	printf ("\n");

	printf("Digit2 is: ");
	printColor(digit2);
	printf("\n");

	printf("Digit3 is: ");
	printColor(digit3);
	printf("\n");

	return 0;
}

void printColor(char digit) {
   if (digit == '0')
	printf("Black");
   else if (digit == '1')
	printf("Brown");
   else if (digit == '2')
	printf("Red");
   else if (digit == '3')
	printf("Orange");
   else if (digit == '4')
	printf("Yellow");
   else if (digit == '5')
	printf("Green");
   else if (digit == '6')
	printf("Blue");
   else if (digit == '7')
	printf("Violet");
   else if (digit == '8')
	printf("Gray");
   else if (digit == '9')
	printf("White");
   else
	printf("invalid");
   return;
}


This post has been edited by no2pencil: 06 July 2010 - 09:33 PM
Reason for edit:: Added code tags

Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5191
  • View blog
  • Posts: 26,897
  • Joined: 10-May 07

Re: Fatal error code

Posted 06 July 2010 - 09:38 PM

Works fine for me...

Quote

>$vi digit.c
>$make digit
cc digit.c -o digit
>$./digit
Enter 3 digits>123
Digit1 is: Brown
Digit2 is: Red
Digit3 is: Orange


Oh, are you maybe trying to compile your code while the exe is still running? Check to see if your code is still running, if you can't find it, try a reboot. I'll bet that's what has happened.
Was This Post Helpful? 0
  • +
  • -

#5 sawyer686  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-July 10

Re: Fatal error code

Posted 06 July 2010 - 09:44 PM

View Postno2pencil, on 06 July 2010 - 08:38 PM, said:

Works fine for me...

Quote

>$vi digit.c
>$make digit
cc digit.c -o digit
>$./digit
Enter 3 digits>123
Digit1 is: Brown
Digit2 is: Red
Digit3 is: Orange


Oh, are you maybe trying to compile your code while the exe is still running? Check to see if your code is still running, if you can't find it, try a reboot. I'll bet that's what has happened.


Im going to reboot now and see if that works. Thankyou :)
Was This Post Helpful? 0
  • +
  • -

#6 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1628
  • View blog
  • Posts: 3,090
  • Joined: 30-May 10

Re: Fatal error code

Posted 06 July 2010 - 10:17 PM

> I ran the program once and t wrked with no errors. When I tried to run it again and got
> POLINK:fatal error: Access is denied ***error code: 1***.
Are you sure the first instance has truly ended?
Are you still debugging? or has the debugger just detached from the exe?

Because the problem is the linker is not able to write to the exe, and the usual reason for this is that it is still running.

If it happens again, check with task manager to see if it's still running.
Was This Post Helpful? 0
  • +
  • -

#7 Guest_c.user*


Reputation:

Re: Fatal error code

Posted 06 July 2010 - 11:28 PM

digit1 >= 48 && digit1 <= 57

try
#include <ctype.h>

...

    if (isdigit(digit1) && isdigit(digit2) && isdigit(digit3))
        ...



Was This Post Helpful? 1

Page 1 of 1