evaluation of (std::cin >> var) explanation needed.

Discussion in 'C++' started by Subsonics, Sep 4, 2010.

  1. Subsonics

    Subsonics New Member

    Joined:
    Sep 4, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hey, I'm picking up C++. I have a question about the evaluation of the following:

    Code:
    int var;

    if(std::cin >> var)
    //do something
    It's my understanding that this evaluates to true as long as the input is not end-of-file or a non int. But what is it that is returned exactly? Tried this:

    Code:
    while( (void *ret = (std::cin >> var)) ){
    printf("%d, %p, %d\n", var, ret, *((int*)(ret)));
    }
    I have found out that it's a void* but, it's not an object (hence the cast), well what is it then?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice