JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Categories: c++ language in hindi

C++ : I/O COMMAND , The Standard Output Stream (cout) , Input Stream (cin) , Error Stream (cerr) ,Log Stream (clog)

Input Stream (cin) , Error Stream (cerr) ,Log Stream (clog) , C++ : I/O COMMAND , The Standard Output Stream (cout) :-
c++ statndard  input / output opertaion के लिए कई सारे कमांड्स को introduce किया है | अब इस article मे in सभी कमांड्स को discuss करेगे |
c++ I/O stream मे execute होता है जो की bytes के sequence के साथ execute होता है जब bytes a device like a keyboard, a disk drive, or a network connection etc. से  main memory की और transfer होता है तब इसे input operation कहते है | जब stream main memory से a device like a display screen, a printer, a disk drive, or a network connection, etc. की तरह मूव होता है तब इसे आउटपुट operation कहते है |
I/O Library Header Files
c++ प्रोग्राम मे निन्म header files होता है :-
1.<iostream>
इस file मे  cin, cout, cerr and clog objects है इन objects को निन्म condition के लिए use किया जाता है :
cin : इस operation का use standard input stream के लिए किया जाता है |
cout: इस operation का use standard output stream के लिए किया जाता है |
cerr : इस operation का use un-buffered standard error stream के लिए किया जाता है |
clog : इस operation का use buffered standard error stream के लिए किया जाता है |
2.<iomanip>
इस file का use formatted I/O operation जिसे parameter stream manipulators (setw या setprecision)के लिए किया जाता है |
3.<fstream>
इस file का use user-controlled file processing के लिए किया जाता है | इस प्रोसेस / file को file heading के article मे discuss करेगे | basic इस file मे input और आउटपुट operations को perform किया जाता है |
The Standard Output Stream (cout)
ostream class का object cout है | cout operation को connected to भी कहते है जिसे standard output device से display screen के बीच stream को pass किया जाता है |cout को stream insertion operator के साथ use किया जाता है | इसका syntax << होता है |
उदाहरन :
#include <iostream>
using namespace std;
int main() {
char str[] = “Hello ! Welcome “;
cout << “Value of str is : ” << str << endl;
}
जब इस प्रोग्राम को execute किया जाता है तब इसका आउटपुट होता है : −
Value of str is : Hello ! Welcome
c++ complier variable के type को define करने इसे stream insertion मे tranfer किया जाता है जहा पर इसे display किया जाता है | इस function << operator को output data items से overload किया जा सकता है |
किसी एक statement मे दो या दो से अधिक << को use किया जा सकता है |endl का use new line command के लिए किया जाता है |
The Standard Input Stream (cin)
istream class का object cin है | cin  operation standard input device, keyboard या mouse से  connect होता  है जिसे statandard input  device से display screen के बीच stream को pass किया जाता है |cin  को stream extraction operator के साथ use किया जाता है | इसका syntax >> होता है |
Source Code
#include <iostream>
using namespace std;
int main() {
char name[50];
cout << “Please enter name: “;
cin >> name;
cout << “Your name is: ” << name << endl;
}
जब उदाहरन को execute किया जाता है तब इसमें यूजर द्वारा name को input किया जाता है और इसे display किया जाता है | इसका आउटपुट होगा :-
Please enter name: Parth
Your name is: Parth
c++ complier variable के type को define करने इसे stream insertion मे tranfer किया जाता है जिसमे data को assign किया जाता है | नीचे दिए उदाहरनो मे ,
integer value को age मे assign किया जाता है |
cin>>age ;
अगर यूजर द्वारा multiple value को input कराया जाता तब cin statement निन्म होता है :
cin >> name >> age;
इस statement को निन्म तरह से लिख सकते है :-
cin >> name;
cin >> age;
The Standard Error Stream (cerr)
istream class का object cerr है | cerr  operation का use standard error device से releated error message को display करने के लिए किया जाता है  |object  cerr उन-defined buffered है अतः इस stream मे pass सभी data display screen पर तुरंत display हो जाता है |
उदाहरन :
#include <iostream>
using namespace std;
int main() {
char str[] = “Unable to read….”;
cerr << “Error message : ” << str << endl;
}
जब इस function को execute किया जाता है तब इसका आउटपुट होगा :-
Error message : Unable to read….
The Standard Log Stream (clog)
istream class का object clog है | clog operation का use standard error device से releated error message को display करने के लिए किया जाता है  |object  cerr defined buffered है अतः इस stream मे pass सभी data display screen पर तुरंत display हो जाता है | इस command से buffer मे error message तब तक सेव रहता है जब तक buffer full नहीं हो जाता है या इसे flush नहीं किया जा सकता है |
इसका उदाहरन निन्म है :
#include <iostream>
using namespace std;
int main() {
char str[] = “Unable to read….”;
clog << “Error message : ” << str << endl;
}
जब उदाहरन को execute किया जाता है तब इसमें यूजर द्वारा name को input किया जाता है और इसे display किया जाता है | इसका आउटपुट होगा :-
Error message : Unable to read….
इन छोटे उदाहरनो से इन सभी commands cout, cerr and clog मे differnce को समजना थोडा मुश्किल है | लेकिन जब प्रोग्राम की length काफी बड़ी होती है तब इन commands मे difference को अच्छी तरह से देखसकते है |
Sbistudy

Recent Posts

सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है

सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…

18 hours ago

मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the

marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…

18 hours ago

राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi

sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…

2 days ago

गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi

gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…

2 days ago

Weston Standard Cell in hindi वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन

वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन Weston Standard Cell in…

3 months ago

polity notes pdf in hindi for upsc prelims and mains exam , SSC , RAS political science hindi medium handwritten

get all types and chapters polity notes pdf in hindi for upsc , SSC ,…

3 months ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now