std::fpos::state - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::fpos::state

From cppreference.com
< cpp‎ | io‎ | fpos

State state() const; | (1) |
void state( State st ); | (2) |

Manages the file position state.

1) Returns the value of the file position state
2) Replaces the file position state with the value of `st`.

For the specializations of std::fpos that are used in the standard library, `State` is always std::mbstate_t

### [edit] Parameters

st | - | new value for the state

### [edit] Return value

1) the current value of the fpos state
2) (none)

### [edit] Example

Run this code

    #include <iostream>
    #include <sstream>
    #include <cwchar>

    int main()
    {
        std::istringstream s("test");
        std::mbstate_t st = s.tellg().state();

        if(std::mbsinit(&st))
            std::cout << "The stream is in the initial shift state\n";
    }

Output:

    The stream is in the initial shift state

### [edit] See also

mbstate_t | conversion state information necessary to iterate multibyte character strings (class) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/io/fpos/state&oldid=62370"