Thread: WHAT is going ON!?

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    14

    WHAT is going ON!?

    Okay, i'm getting this really odd error message...26 times.

    The message is:
    Error E2206 1: Illegal character ' ' (0x0)
    My code to classify a triangle.
    Code:
    #include <iostream>
    #include <cstdlib>
    #include <cmath>
    
    using namespace std;
    
    int main()
    {
    	int co1x;
    	int co1y;
    	int co2x;
    	int co2y;
    	int co3x;
    	int co3y;
    	int dis1;
    	int dis2;
    	int dis3;
    
    	cout<<"Enter the coordinates of the triangle" << endl;
    	cout<<"X coordinate of point 1: " << flush;
    	cin.ignore();
    	cin>>co1x;
    	cout<<"Y coordinate of point 1: "<< flush;
    	cin.ignore();
    	cin>>co1y;
    	cout<<"X coordinate of point 2: "<< flush;
    	cin.ignore();
    	cin>>co2x;
    	cout<<"Y coordinate of point 2: "<< flush;
    	cin.ignore();
    	cin>>co2y;
    	cout<<"X coordinate of point 3: "<< flush;
    	cin.ignore();
    	cin>>co3x;
    	cout<<"Y coordinate of point 3: "<< flush;
    	cin.ignore();
    	cin>> co3y;
    
    	sqrt((co1x - co2x)^2 + (co1y - co2y)^2) = dis1;
    	sqrt((co2x - co3x)^2 + (co2y - co3y)^2) = dis2;
    	sqrt((co3x - co1x)^2 + (co3y - co1y)^2) = dis3;
    
    	if (dis1 == dis2 && dis2 == dis3 && dis3 == dis1)
    	cout<<"The triangle is equilateral." << endl;
    	
    	else if (dis1 == dis2 && dis2 == dis1)
    	cout<<"The triangle is isoceles." << endl;
    	
    	else if (dis2 == dis3 && dis3 == dis2)
    	cout<<"The triangle is isoceles." << endl;
    
    	else if (dis3 == dis1 && dis1 == dis3)
    	cout<<"The triangle is isoceles." << endl;
    
    	else if (dis3 != dis1 && dis2 != dis1 && dis2 != dis3)
    	cout<<"The triangle is scalene." <<endl;
    	
    	cin.get();
    }
    What is going on!?
    Last edited by Iceboy152; 03-02-2006 at 10:48 AM.

  2. #2
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Post the whole code so I can see what is going on. It is no point posting just the header files and the error line if I cannot read what the program does

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    14
    Done. I put it in the original post.

  4. #4
    C / C++
    Join Date
    Jan 2006
    Location
    The Netherlands
    Posts
    312
    0x0 is a hexadecimal character I think.

    You're sure ^ is a legal C++ character?
    Last edited by Ideswa; 03-02-2006 at 10:24 AM.
    Operating Systems:
    - Ubuntu 9.04
    - XP

    Compiler: gcc

  5. #5
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Code:
    	radical((co1x - co2x)^2 + (co1y - co2y)^2) = dis1
    	radical((co2x - co3x)^2 + (co2y - co3y)^2) = dis2 
    	radical((co3x - co1x)^2 + (co3y - co1y)^2) = dis3
    Even if this made sense you're missing semicolons at the end of each of these lines. Now why are you trying to set a character with magic argument equal to an integer? If there is a function definition you aren't showing us, then post it.
    Sent from my iPadŽ

  6. #6
    Registered User
    Join Date
    Feb 2006
    Posts
    14
    Because he told me to.
    Or at least I think that's what he meant.

    Anyway, I added the semicolons, but it doesn't seem to help.

  7. #7
    Registered User
    Join Date
    Feb 2006
    Posts
    14
    Sorry in advance for the double post.

    Quote Originally Posted by Ideswa
    0x0 is a hexadecimal character I think.

    You're sure ^ is a legal C++ character?
    No. But then again, I'm not sure it isn't, either. If you have a better way to raise a number to a power, please enlighten me.

  8. #8
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Ofcourse it doesn't those lines make no sense. You can't assign a character to an integer and expect the radical to be there. Besides, it looks like what you're trying to do is get the square root. You don't do that by adding a radical character to a number.

    Add <cmath> and use the sqrt() function.
    Sent from my iPadŽ

  9. #9
    Registered User
    Join Date
    Feb 2006
    Posts
    14
    Okay, the error changed.

    I'm also updating the code in the original post.

    Here's the new error:
    Error E2277 39, 40 & 41: Lvalue required
    Just for reference, here's those 3 lines:

    Code:
    sqrt((co1x - co2x)^2 + (co1y - co2y)^2) = dis1;
    	sqrt((co2x - co3x)^2 + (co2y - co3y)^2) = dis2;
    	sqrt((co3x - co1x)^2 + (co3y - co1y)^2) = dis3;

  10. #10
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Why don't use actually find out how to use sqrt() before you just throw it into your program.

    Secondly. You're assigning the return TO A VARIABLE. Not a variable to the function return. disN should be on the left.
    Sent from my iPadŽ

  11. #11
    Registered User
    Join Date
    Feb 2006
    Posts
    14
    Ah...

  12. #12
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Download Dev-C++ and use it. It's magical and it makes money grow on trees.
    Sent from my iPadŽ

  13. #13
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You're sure ^ is a legal C++ character?
    It is, but it does bitwise XOR, not exponentiation.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  14. #14
    Registered User
    Join Date
    Mar 2005
    Posts
    140
    Quote Originally Posted by Iceboy152
    If you have a better way to raise a number to a power, please enlighten me.
    in cmath
    Code:
    double pow(double x, double y);

Popular pages Recent additions subscribe to a feed