Having trouble comparing \r and \n from a text file.

I'm having the weirdest issue.

I'm trying to count characters in a text file, while excluding \r and \n. I opened the file in binary mode. If I use Char == '\r' || Char == '\n' to count those escape characters it works fine. If I use Char != '\r' || Char != '\n' to count everything EXCEPT those escape characters it doesn't work. Here's my code with Char == '\r' || Char == '\n'.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
OTP_InputStream.open("OTP_ALL.txt", ios::binary);

if(!OTP_InputStream.fail()){
   int CharCnt = 0;
   int NonCharCnt = 0;

						 
   OTP_InputStream.get(OTP_InputChar);

   while(!OTP_InputStream.eof()){
      if(OTP_InputChar == '\r' || OTP_InputChar == '\n'){
         NonCharCnt++;

      }else{
         CharCnt++;

      }
							 
      OTP_InputStream.get(OTP_InputChar);

   }
cout << "\nCharCnt: " << CharCnt << endl;
cout << "\nNonCharCnt: " << NonCharCnt << endl;


File Contents =
1
2
3

Output =
CharCnt: 3
NonCharCnt: 4


Here's my code with Char != '\r' || Char != '\n'.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
OTP_InputStream.open("OTP_ALL.txt", ios::binary);

if(!OTP_InputStream.fail()){
   int CharCnt = 0;
   int NonCharCnt = 0;

						 
   OTP_InputStream.get(OTP_InputChar);

   while(!OTP_InputStream.eof()){
      if(OTP_InputChar != '\r' || OTP_InputChar != '\n'){
         CharCnt++;

      }else{
         NonCharCnt++;

      }
							 
      OTP_InputStream.get(OTP_InputChar);

   }
cout << "\nCharCnt: " << CharCnt << endl;
cout << "\nNonCharCnt: " << NonCharCnt << endl;


File Contents =
1
2
3

Output =
CharCnt: 7
NonCharCnt: 0

I understand that not all my code is here. What's going on here?
> if(OTP_InputChar != '\r' || OTP_InputChar != '\n')
If it equals \r, then it has to be != to \n
One way or another, this is always true.
In order for this to be false, the char has to be both \r and \n at the same time (not going to happen).

The inverse of
if(OTP_InputChar == '\r' || OTP_InputChar == '\n')

is
if(!(OTP_InputChar == '\r' || OTP_InputChar == '\n'))

or
if(OTP_InputChar != '\r' && OTP_InputChar != '\n')

Yea.... I figured this out hours ago. I should of deleted this thread but forgot. My logic was off. Thanks for the reply though:)
Topic archived. No new replies allowed.