How do I assign the value from a function to a variable?

This is a discussion on How do I assign the value from a function to a variable? within the C Programming forums, part of the General Programming Boards category; Hi! Im starting with C so sorry about my low knowledge of this. Like I said in the title, how ...

  1. #1
    Registered User
    Join Date
    May 2013
    Posts
    16

    How do I assign the value from a function to a variable?

    Hi! Im starting with C so sorry about my low knowledge of this. Like I said in the title, how do I assign the value from a function to a variable? I mean I have this function:
    Code:
    int EnteroAleatorio(){
    
    rand();
    return rand();
    }
    and I would like to assing the value of EnteroAleatorio to a variable in my main function, but when I try to do it and compile, I got the next error:
    non-lvalue in assignement
    Thanks for your tips and, sorry again about my low knowledge of C ^^

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,401
    Show us your main function, the one that resulted in that compile error.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unable to assign to a variable
    By suryak in forum C Programming
    Replies: 2
    Last Post: 11-16-2011, 10:43 AM
  2. Is it possible to assign a type to a variable?
    By Kennedy in forum C Programming
    Replies: 20
    Last Post: 06-10-2010, 04:46 PM
  3. Assign this to a variable
    By ABuNeNe in forum C Programming
    Replies: 5
    Last Post: 11-25-2009, 09:21 PM
  4. how to assign a map iterator to an int variable?
    By Masterx in forum C++ Programming
    Replies: 22
    Last Post: 05-02-2009, 09:05 AM
  5. Assign string to variable?
    By 98dodgeneondohc in forum C Programming
    Replies: 8
    Last Post: 04-24-2005, 01:51 PM

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