Skip to content

Files

Latest commit

 

History

History
13 lines (7 loc) · 588 Bytes

checkCastIntToCharAndBack.md

File metadata and controls

13 lines (7 loc) · 588 Bytes

Pattern: Saving function return value in char variable

Issue: -

Description

When saving function return value in char variable there is loss of precision. When function returns EOF this value is truncated. Comparing the char variable with EOF can have unexpected results.

For instance a loop while (EOF != (c = func_name()); loops forever on some compilers/platforms and on other compilers/platforms it will stop when the file contains a matching character.

Further Reading