Skip to content

Latest commit

 

History

History
65 lines (51 loc) · 4.21 KB

File metadata and controls

65 lines (51 loc) · 4.21 KB
title Stream States | Microsoft Docs
ms.custom
ms.date 11/04/2016
ms.reviewer
ms.suite
ms.technology
cpp-standard-libraries
ms.tgt_pltfrm
ms.topic article
dev_langs
C++
helpviewer_keywords
streams, states
ms.assetid 5f28c968-f132-403f-968c-8417ff315e52
caps.latest.revision 8
author corob-msft
ms.author corob
manager ghogen
translation.priority.ht
cs-cz
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
pl-pl
pt-br
ru-ru
tr-tr
zh-cn
zh-tw

Stream States

The valid states, and state transitions, for a stream are shown in the following figure.

Stream

Each of the circles denotes a stable state. Each of the lines denotes a transition that can occur as the result of a function call that operates on the stream. Five groups of functions can cause state transitions.

Functions in the first three groups are declared in <stdio.h>:

Functions in the remaining two groups are declared in <wchar.h>:

The state diagram shows that you must call one of the position functions between most write and read operations:

  • You cannot call a read function if the last operation on the stream was a write.

  • You cannot call a write function if the last operation on the stream was a read, unless that read operation set the end-of-file indicator.

Finally, the state diagram shows that a position operation never decreases the number of valid function calls that can follow.

See Also

Files and Streams