file handling in c++
C++ के द्वारा files को भी handle किया जा सकत है। इसके लिए C++ आपको streams provide करती है। Basically C++ में आप files के साथ नीचे दिए गए tasks perform कर सकते है।
Opening a file
Reading from a file
Writing to a file
Closing a file
C++ में file handling support provide किये जाने का मुख्य कारण output को permanently _store करना है। Normally जब भी आप कोई program run करते है तो उसका output monito पर show होता है। जैसे ही आप output console window से exit होते है तो आपके program का output of lost जाता है।
ऐसी situation में एक ऐसे mechanism की requirement थी जिससे की output को permanently hard disk u fant file store किया जा सके और जरुरत पड़ने पर उसे वापस retrieve किया जा सके।
C++ में file handling provide किये जाने का दूसरा मुख्य कारण output को दुबारा यूज़ करना है। एक बार जब आप output को file में store करवा ले तो उसे future में वापस भी यूज़ कर सकते है। उदाहरण के लिए आप इसे किसी दूसरे program input के रूप में यूज़ कर सकते है।
में
आगे file handling में यूज़ होने वाली stream classes के बारे में बताया जा रहा है। यदि आपको streams का concept clear नहीं है तो आप C++ I/O System tutorial में पढ़ सकते है।