Re: stupid error doing my head it! (C programming)

From: Will Twentyman (wtwentyman_at_read.my.sig)
Date: 07/14/04


Date: Wed, 14 Jul 2004 11:49:19 -0400

spleen wrote:

> Hiya,
>
> Im using visual C++ 6.0 to write my code and when i go to compile im
> getting a stupid error that i just can't figure out how to solve no
> matter how i look at it, as im sure im right! this is the error it
> throws up..
>
> error C2106: '=' : left operand must be l-value
>
> ive used google and tried to find if theres a work around but as far
> as im concerned im correct (probably wont be....
>
> heres my code, if that would help...I dont like asking for help but
> its been 2hrs ive tried to fix it now and it just doesnt work for some
> reason thats a mystery to me!

Let's start with buffer not clearly defined in this code snippet.

> for(h=1; h>=height; h++)

This loop either never runs or never stops.

> {
> for(w=1; w>=width; w++)

This loop either never runs or never stops.

> {
> int i = 1;
> char ascii[10];
> char c[10];
> int a;
>
> c = buffer[i]; */offending line/*

c is a const pointer to char, buffer[i] is presumably of type char. c
is not an l-value (something that can be reassigned).

> sprintf( ascii, "%d", c );
> a = atoi(ascii);
>
> fprintf(f, "%d, %d, %d\n", h, w, a);
> i = i + 1;
> }
> }
> while(h * w <= height * width);

This is a loop that either never runs or never halts.

>
> where i have put */offending line/* is where the complier says is my
> error,
>
> thanks for any advice!

Believe the compiler when it gives you an error. The compiler is either
correct or not standards compliant, but those are about the only two
options.

-- 
Will Twentyman
email: wtwentyman at copper dot net


Relevant Pages

  • Re: Letter to US Sen. Byron Dorgan re unpaid overtime
    ... >> both less efficient and less safe than the Fortran and Basic standard. ... >> The C for loop is actually trying to do what a do loop does. ... sloppy thinking that results from confusing a programming language ... > I do not believe that you are capable of writing a conforming C compiler. ...
    (comp.programming)
  • Re: Letter to US Sen. Byron Dorgan re unpaid overtime
    ... it's a for loop in the C sense. ... > sloppy thinking that results from confusing a programming language ... >> I do not believe that you are capable of writing a conforming C compiler. ... Does Microsoft's C compiler perform this optimisation? ...
    (comp.programming)
  • Re: Histogram of character frequencies
    ... generated object code may simply be a loop in which elements are ... believe any C compiler anywhere would reject it. ... On the first iteration of the loop you test the end of file indicator ...
    (comp.lang.c)
  • Re: Fridays the thirteenth. (And a little puzzle.)
    ... -- compiler) is the usual method ... int febdays ... -- We're going to go round a loop dealing with each year in turn. ... -- other languages call) ...
    (uk.people.silversurfers)
  • Re: Interesting article by Randall Hyde
    ... >>> a test before executing the loop. ... is a compiler writer forced to ... And another thing you might consider is that compiler optimization was ... Then the programmer will have to protect the execution of that loop. ...
    (comp.lang.asm.x86)