0

I have encountered this type of "stray '\342' in program" error for the first time.

Below is my code

#include <bits/stdc++.h>

using namespace std;

#define sc(n) scanf("%d",&n)
#define tc1 cin>>t;while(t--)
#define forf(i, a, b) for(i =(a); i <(b); ++i)

int main()
{
    long long int t, x1, x2, x3, y1, y2, y3, points, temp;

    float area;
    tc1
    {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        temp = x1*y2 + x2*y3 + x3*y1 −x1*y3 − x3*y2 − x2*y1;
        area = 0.5f * abs(temp);
        points = area + 1 - (3/2);
        cout << points << "\n";
    }
    return 0;
}

Below is my compiler error:

solution.cc:18:9: error: stray '\342' in program
     temp=x1*y2 +x2*y3 + x3*y1 −x1*y3 − x3*y2 − x2*y1;
     ^
solution.cc:18:9: error: stray '\210' in program
solution.cc:18:9: error: stray '\222' in program
solution.cc:18:9: error: stray '\342' in program
solution.cc:18:9: error: stray '\210' in program
solution.cc:18:9: error: stray '\222' in program
solution.cc:18:9: error: stray '\342' in program
solution.cc:18:9: error: stray '\210' in program
solution.cc:18:9: error: stray '\222' in program
solution.cc: In function 'int main()':
solution.cc:18:38: error: expected ';' before 'x1'
     temp=x1*y2 +x2*y3 + x3*y1 −x1*y3 − x3*y2 − x2*y1;
                                  ^

What is the the meaning of this error?

I am not able to understand the exact meaning of this error by previously asked answered questions.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
chinmay
  • 9
  • 4
  • The real duplicate is the canonical *[Compilation error: stray ‘\302’ in program, etc.](https://stackoverflow.com/questions/19198332)*. – Peter Mortensen Mar 06 '21 at 15:04
  • 342 210 222 (octal) → 0xE2 0x88 0x92 (hexadecimal) → UTF-8 sequence for Unicode code point U+2212 ([MINUS SIGN](https://www.utf8-chartable.de/unicode-utf8-table.pl?start=8704&number=128)) - different from the ASCII one. – Peter Mortensen Mar 06 '21 at 20:36

1 Answers1

1

It looks like you have incorrect characters in your formula.

temp=x1*y2 +x2*y3 + x3*y1 −x1*y3 − x3*y2 − x2*y1;

Is not the same as

temp=x1*y2 +x2*y3 + x3*y1 -x1*y3 - x3*y2 - x2*y1;

As you can see the (-) are different.

NathanOliver
  • 171,901
  • 28
  • 288
  • 402