Thread: invalid lvalue in assignment

  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    2

    invalid lvalue in assignment

    The red line is where the compiler tells me there is an error: invalid lvalue in assignment. Help please
    Code:
    #include <stdio.h>
    #include "genlib.h"
    #include "simpio.h"
    
    void GetTime(long SysSecs, int *hours,int *minutes,int *seconds);
    main()
    {
        long SysSecs;
        int hours, minutes, seconds;
        printf("Enter device seconds: ");
        SysSecs = GetLong();
        GetTime = (SysSecs, &hours, &minutes, &seconds);
        printf("Time is: %d:%d:%d\n", hours, minutes, seconds);
    }
    void GetTime(long SysSecs, int *hours,int *minutes,int *seconds)
    {
        *hours = SysSecs / 3600;
        *minutes = SysSecs / 60;
        *seconds = SysSecs % 60;
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > GetTime = (SysSecs, &hours, &minutes, &seconds);
    Why are you using = here?

    You're trying to call the function.
    See your prior call to printf for how that works.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    You should not assign the arguments to a function.

    Code:
    GetTime(SysSecs, &hours, &minutes, &seconds);
    lvalue (short for left value) refers to it's position related to the assignment operator '='.

  4. #4
    Registered User
    Join Date
    Aug 2012
    Posts
    2
    oh dear god..result of my tiredness..THANK YOU!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. invalid lvalue in assignment ?
    By MSkiLLz in forum C++ Programming
    Replies: 5
    Last Post: 12-06-2010, 10:55 AM
  2. invalid lvalue in assignment
    By ChoCo in forum C Programming
    Replies: 2
    Last Post: 08-07-2009, 01:06 PM
  3. :523: error: invalid lvalue in assignment
    By nasim751 in forum C Programming
    Replies: 10
    Last Post: 04-14-2008, 04:08 AM
  4. invalid lvalue in assignment
    By saipkjai in forum C++ Programming
    Replies: 8
    Last Post: 06-21-2007, 03:19 PM
  5. invalid lvalue in assignment
    By antonis in forum C Programming
    Replies: 8
    Last Post: 10-09-2005, 12:00 PM