Thread: l-value complaint from compiler

  1. #1
    Railgun God |Wiz|'s Avatar
    Join Date
    Sep 2005

    l-value complaint from compiler

    this is my code:
    #include <iostream>
    using namespace std;
    int primedivisor ( int original)
    int vr;
    int collective = 1;
    int n = 2;
    while (n != collective)
    if (0 = original % n)
    vr = n;
    original /= n;}
    else {n++;}
    return vr;
    int main()
    {int x;
    cin >> x;
    cout << primedivisor (x);
    return 0;}
    and this is my error:

    a.cpp<12> : error C2106: '=' : left operand must be l-value

    I tried making pointers and sticking them in, putting 1 instead of "original", switching it around, and making all sorts of different types of variables (char, float, etc.)

    nothing can take away the message.

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Ontario, Canada
    You're using the assignment operator. == is comparison.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Railgun God |Wiz|'s Avatar
    Join Date
    Sep 2005
    wow - that was fast!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  2. Compiler Paths...
    By Cobra in forum C++ Programming
    Replies: 5
    Last Post: 09-26-2006, 04:04 AM
  3. C Compiler and stuff
    By pal1ndr0me in forum C Programming
    Replies: 10
    Last Post: 07-21-2006, 11:07 AM
  4. I can't get this new compiler to work.
    By Loduwijk in forum C++ Programming
    Replies: 7
    Last Post: 03-29-2006, 06:42 AM
  5. how to call a compiler?
    By castlelight in forum C Programming
    Replies: 3
    Last Post: 11-22-2005, 11:28 AM