Newbie Question. How do you check if array is empty? and a variableis not assigned to anything?

Discussion in 'C Programming' started by chutsu, Jun 2, 2009.

  1. chutsu

    chutsu Guest

    As the title says:
    How do you check if array is empty?
    And also how do you check that a variable is not assigned to
    anything?
     
    chutsu, Jun 2, 2009
    #1
    1. Advertisements

  2. chutsu

    chutsu Guest

    But what if your C program requires input from a user. How do you
    check if the user has entered anything at all instead of just pressing
    enter?
    Thanks
    Chris
     
    chutsu, Jun 2, 2009
    #2
    1. Advertisements

  3. chutsu

    Sjouke Burry Guest

    Check your program.
    No variable is ever assigned to anything.

    It can be use for millions of purposes.
     
    Sjouke Burry, Jun 2, 2009
    #3
  4. That's a *very* different question, and it depends on how you're
    reading the input. Richard Heathfield posted some good information.
    You might also take a look at section 12 of the comp.lang.c FAQ,
    <http://www.c-faq.com/>.
     
    Keith Thompson, Jun 2, 2009
    #4
  5. Typical Heathfield bullshit.

    If you have a static variable, then there is no undefined behavior
    involved in "looking it at" or using it in any other way even before
    you've assigned it a value.
     
    Antoninus Twink, Jun 3, 2009
    #5
  6. chutsu

    Willem Guest

    Antoninus Twink wrote:
    ) On 2 Jun 2009 at 22:07, Richard Heathfield wrote:
    )> If a variable (or rather, an object) has not been assigned a value,
    )> you're not allowed to look at it. All you can do is assign to it.
    )
    ) Typical Heathfield bullshit.
    )
    ) If you have a static variable, then there is no undefined behavior
    ) involved in "looking it at" or using it in any other way even before
    ) you've assigned it a value.

    That's because static variables are implicitly assigned zero values.
    So they can't have not been assigned a value.


    SaSW, Willem
    --
    Disclaimer: I am in no way responsible for any of the statements
    made in the above text. For all I know I might be
    drugged or something..
    No I'm not paranoid. You all think I'm paranoid, don't you !
    #EOT
     
    Willem, Jun 3, 2009
    #6
  7. Exactly so.

    "The word "pedant" is used by people who don't care about correctness to
    describe people who do." (R Heathfield, writing from a glass house
    somewhere in England)
     
    Antoninus Twink, Jun 3, 2009
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.