error C2105: '++' needs l-value

This is a discussion on error C2105: '++' needs l-value within the C Programming forums, part of the General Programming Boards category; Hi, I've problem with compile this code (using VC++ 2010). I've got an error "error C2105: '++' needs l-value" ... ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    1

    error C2105: '++' needs l-value

    Hi, I've problem with compile this code (using VC++ 2010). I've got an error
    "error C2105: '++' needs l-value" ... on penultimate row but I can't figurate, what's the problem.

    Code:
    int Push(double value)
    {
    	if(stack == NULL)
    		return 1;
    	if(position+sizeof(double) > stack+size)
    		return 1;
    	*(double*)position = value;
    	((double*)position)++;              // ON THIS LINE I GET ERROR                        
    	return 0;
    }

  2. #2
    -bleh-
    Join Date
    Aug 2010
    Location
    somewhere in this universe
    Posts
    460
    Position has never been declared or passed into that function unless it's global. You can't just cast anything to a pointer and use pointer arithmetic.
    "All that we see or seem
    Is but a dream within a dream." - Poe

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21