Warning C4244

closed account (LN7oGNh0)
Ive looked up on this warning, but i dont really understand what is being explained in the code. This warning comes up but the console window comes up. Also the console window does not display anything. I think it might have something to do when I assign 'result to primeFactor % num.' (because primeFactor is along long int whilst return is just int). What i want the code to do is find the lowest factor of primeFactor. So I made a loop which continuously tests if the remainder is 0 then displays num. (So it finds what number divides evenly into primeFactor. Anyway here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include < iostream>

using namespace std;

//Foward declaration of function used to find the remainder
int findRemainder(int x, int y)
{
	return x % y;
}
int main()
{
for(int num = 2; num < 100; num++)
{
long long int primeFactor = 600851475143;
int result = findRemainder(primeFactor, num);
if (result = 0)
cout << num;
}
cin.get();
return 0 ;
}


NOTE: I know that primeFactor isnt prime. (ill fix it later.)
Last edited on
Maybe its because you use the assignment operator(=) instead of the equal to operator(==) in line 16?
I've no idea what C5344 means.

However, this code is not correct:
if (result = 0)

That's because the assignment operator = is used rather than the comparison operator ==.

The reason why it is a warning, rather than an error is because the code is valid, and it's possible that it might have been deliberate. But I'm just about certain that in this case it wasn't deliberate, and thus really is an error.

I see this same problem was already highlighted in an earlier post by whitenite1 http://www.cplusplus.com/forum/beginner/87677/#msg470301
Topic archived. No new replies allowed.