I'm compiling as debug, but compiling as release still does the same thing. I still get the same issue running it in release or debug in the IDE and running the generated .exe in the console. I simplified the program like this:
EDIT: I also want to say i uninstalled VS and reinstalled it, same issue. Im going to try code blocks again and see what happens.
EDIT 2: The same thing happens when compiling this in code::blocks so its not VS specific.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <iostream>
int main()
{
int num{ 0 };
for (int i{ 0 }; i < 50; ++i)
{
std::cout << num++ << '\n';
}
std::cin.get();
return 0;
}
|
and this produces:
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 21
22
23
24
25
26
27
28
29
|
I copy pasted that from the console so thats exactly as i saw it outputted.
Deleting the .pdb file makes the program run as expected, but also, so does modifying the program in any way. even if i just add a space and save it, it will output correctly, also if i do Build > Rebuild Solution, then hit run without debuggin, it will work correctly every time. The issue is that when i run it would doing any of those things, i get that garbage output. This code works on my laptop, on online IDE's and I created a new user account on my pc and tried it and it works correctly on that profile, so it has to do with my specific profile, but switching profiles for this issue is not something i can do, So I have to try to figure it out.
I deleted VS 22's cache files, did sfc /scannow, nothing fixed it so far. But it has to have something to do with the way its building the program, if rebuilding the program and running it makes it work that has to be a clue to something, I just dont know what.
Rebuilding and running produces this output every time, which is whats expected:
0
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
42
43
44
45
46
47
48
49 |