1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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