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

Question Tag Definition in english with examples upsc ssc ias state pcs exames important topic

Question Tag Definition • A question tag is a small question at the end of a…

2 weeks ago

Translation in english grammer in hindi examples Step of Translation (अनुवाद के चरण)

Translation 1. Step of Translation (अनुवाद के चरण) • मूल वाक्य का पता करना और उसकी…

2 weeks ago

Report Writing examples in english grammer How to Write Reports explain Exercise

Report Writing • How to Write Reports • Just as no definite rules can be laid down…

2 weeks ago

Letter writing ,types and their examples in english grammer upsc state pcs class 12 10th

Letter writing • Introduction • Letter writing is an intricate task as it demands meticulous attention, still…

2 weeks ago

विश्व के महाद्वीप की भौगोलिक विशेषताएँ continents of the world and their countries in hindi features

continents of the world and their countries in hindi features विश्व के महाद्वीप की भौगोलिक…

2 weeks ago

भारत के वन्य जीव राष्ट्रीय उद्यान list in hin hindi IAS UPSC

भारत के वन्य जीव भारत में जलवायु की दृष्टि से काफी विविधता पाई जाती है,…

2 weeks 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