Cannot open file

closed account (DNA7fSEw)
I am writing code to calculate GCD.
I use Visual Studio 2015
When I try to rebuild solution, it says it cannot open the program file.
Is it a problem with the code?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  #include "stdafx.h"


int main()
{
	int num1, num2, mod, choice, loops;
	printf("\nEnter 2 numbers greatest first\n/");
	scanf("%d %d", &num1, &num2);
	printf("Enable debug mode?\n1 = yes 0 = no\n/");
	scanf("%d", &choice);
	printf("\n");
	mod = 1;
	loops = 0;
	while (1)
	{
		mod = num1 % num2;
		if (mod != 0)
		{
			num1 = num2;
			num2 = mod;
		}
		else
		{
			break;
		}
		loops = loops + 1;
		if (choice != 0)
		{
			printf("1: %d", num1);
			printf("2: %d", num2);
			printf("M: %d", mod);
			printf("L: %d", loops);
		}
		
	}
	printf("%d", num2);
	printf("\n");
	return 0;
}

Last edited on
It say it cannot open a file.


I really don't see where you are trying to open a file.

It really seems weird that your while loop is always true. Also, when your mod is zero it will break out of the while loop and completely miss the choice condition. Maybe it would be better to put that above the condition of mod != 0.

Why don't you want to make the condition of the while loop as mod != 0?

-Hirokachi
How are you using printf and all, without including <stdio.h>
@Runner Pro Agario - It's probably in the header file "stdafx.h"
Oh right, I actually never looked in the file before, thats why.
Topic archived. No new replies allowed.