a program i wrote and gives me all the time: POLINK: fatal error: Access is denied.

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2008
Posts: 1
Reputation: amit.turkaspa is an unknown quantity at this point 
Solved Threads: 0
amit.turkaspa amit.turkaspa is offline Offline
Newbie Poster

a program i wrote and gives me all the time: POLINK: fatal error: Access is denied.

 
0
  #1
Dec 15th, 2008
hallo i wrote a program with 3 different functions.
something wrong with her and i cant see it.
  1. #include<stdio.h>
  2. int devide9(int num);
  3. int decimal_binar(int num);
  4. int binar_decimal(int num);
  5. int main()
  6. {
  7. int menu, num9, numd1, numb1, numd2, numb2, numfinal1;
  8.  
  9. printf("\nHallo these are your options:\n");
  10. printf("1. Check if your number can be devide by 9 without residue.\n");
  11. printf("2. Decimal - binar converter.\n");
  12. printf("3. Binar - decimal converter.\n");
  13. printf("4. Exit.\n");
  14. scanf("%i", &menu);
  15.  
  16. switch (menu)
  17. {
  18. case 1:
  19. printf("please enter a number:\n");
  20. scanf("%i", &num9);
  21. numfinal1 = devide9(num9);
  22. if (numfinal1 == 9)
  23. printf("the number can be devided by 9.\n");
  24. else
  25. printf("the number can not be devided by 9.\n");
  26. main();
  27. case 2:
  28. printf("please enter a number:\n");
  29. scanf("%i", &numd1);
  30. numb1 = decimal_binar (numd1);
  31. if (numd1<0)
  32. printf("%i (base 10) => -%i (base 2)\n", &numd1, &numb1);
  33. else
  34. printf("%i (base 10) => %i (base 2)\n", &numd1, &numb1);
  35. main();
  36. case 3:
  37. printf("please enter a number:\n");
  38. scanf("%i", &numb2);
  39. numd1 = binar_decimal(numb2);
  40. if (numd2<0)
  41. printf("%i (base 2) => -%i (base 10)\n", &numb2, &numd2);
  42. else
  43. printf("%i (base 2) => %i (base 10)\n", &numb2, &numd2);
  44. main();
  45. case 4:
  46. return(0);
  47. break;
  48. default: main(); break;
  49.  
  50. }
  51. return(0);
  52. }
  53.  
  54. int devide9 (int num)
  55. {
  56. int numT, num1;
  57. if (num<0)
  58. num = num*-1;
  59. numT = 0;
  60. while (num > 0 );
  61. {
  62. num1 = num%10;
  63. numT = num1 + numT;
  64. num = num/10;
  65. }
  66. if (numT>9)
  67. numT = devide9 (numT);
  68. return (numT);
  69. }
  70.  
  71. int decimal_binar (int num)
  72. {
  73. int counter, multi, i, numT, num1, numd1;
  74. if (num<=1023 && num >= -1023)
  75. {
  76. if (num<0)
  77. num = num*-1;
  78. counter = 0;
  79. numT = 0;
  80. while (num > 0 );
  81. {
  82. num1 = num % 2;
  83. num = num / 2;
  84. if (counter == 0)
  85. numT = num1;
  86. else
  87. {
  88. multi = 1;
  89. for (i=1; i<=counter; i++)
  90. {
  91. multi = 10 * multi;
  92. }
  93. }
  94. numT = multi * num1 + numT;
  95. counter = counter +1;
  96. }
  97. }
  98. else
  99. {
  100. printf("please enter a new number:\n");
  101. scanf("%i", &numd1);
  102. numT = decimal_binar(numd1);
  103. }
  104. return (numT);
  105. }
  106.  
  107.  
  108. int binar_decimal (int num)
  109. {
  110. int num1, counter, hez1, hezT, i,numT, numb1;
  111. counter = 0;
  112. if (num >= -1111111111 && num <= 1111111111)
  113. {
  114. if (num < 0)
  115. num = num*-1;
  116. counter = 0;
  117. numT = 0;
  118. while (num > 0 );
  119. {
  120. num1 = num % 10;
  121. hez1 = hezT = 1;
  122. for (i=1; i<=counter; i++)
  123. {
  124. hez1 = hezT;
  125. hezT = hez1*2;
  126. }
  127. numT = num1*hezT + numT;
  128. counter = counter + 1;
  129. num = num / 10;
  130. }
  131. }
  132. else
  133. {
  134. printf("please enter a new number:\n");
  135. scanf("%i", &numb1);
  136. numT = binar_decimal (numb1);
  137. }
  138. return (numT);
  139. }
Last edited by Narue; Dec 15th, 2008 at 12:16 pm. Reason: added code tags
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 146
Reputation: devnar will become famous soon enough devnar will become famous soon enough 
Solved Threads: 16
devnar's Avatar
devnar devnar is offline Offline
Junior Poster

Re: a program i wrote and gives me all the time: POLINK: fatal error: Access is denied.

 
0
  #2
Dec 15th, 2008
Use code tags and indent your code properly.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: a program i wrote and gives me all the time: POLINK: fatal error: Access is denied.

 
0
  #3
Dec 15th, 2008
> POLINK: fatal error: Access is denied.
There's a good chance that the previous attempt at this code is still running, and that you can't overwrite a running programs' executable.

Oh, and don't call main() recursively, use a loop.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 90
Reputation: ajay.krish123 is an unknown quantity at this point 
Solved Threads: 8
ajay.krish123 ajay.krish123 is offline Offline
Junior Poster in Training

Re: a program i wrote and gives me all the time: POLINK: fatal error: Access is denied.

 
0
  #4
Dec 26th, 2008
main() function cannot be called again and again.
Instead you can use another function in place of it or use
  1. goto label;
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 146
Reputation: devnar will become famous soon enough devnar will become famous soon enough 
Solved Threads: 16
devnar's Avatar
devnar devnar is offline Offline
Junior Poster

Re: a program i wrote and gives me all the time: POLINK: fatal error: Access is denied.

 
0
  #5
Dec 26th, 2008
Originally Posted by ajay.krish123 View Post
main() function cannot be called again and again.
Instead you can use another function in place of it or use
  1. goto label;
Use of goto is frowned upon. The only place where it's usage is justified is when you're in a nest of loops and wanna come out of it with the least amount of hassle. As Salem has already suggested, loop is the best way to go about this particular problem.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 90
Reputation: ajay.krish123 is an unknown quantity at this point 
Solved Threads: 8
ajay.krish123 ajay.krish123 is offline Offline
Junior Poster in Training

Re: a program i wrote and gives me all the time: POLINK: fatal error: Access is denied.

 
0
  #6
Dec 26th, 2008
Originally Posted by devnar View Post
Use of goto is frowned upon. The only place where it's usage is justified is when you're in a nest of loops and wanna come out of it with the least amount of hassle. As Salem has already suggested, loop is the best way to go about this particular problem.
As i already stated above him to use the another function
goto() statements is the last option to use in the program when nothing works.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC