JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi sociology physics physical education maths english economics geography History

chemistry business studies biology accountancy political science

Class 12

Hindi physics physical education maths english economics

chemistry business studies biology accountancy Political science History sociology

Home science Geography

English medium Notes

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Class 12

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

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

four potential in hindi 4-potential electrodynamics चतुर्विम विभव किसे कहते हैं

चतुर्विम विभव (Four-Potential) हम जानते हैं कि एक निर्देश तंत्र में विद्युत क्षेत्र इसके सापेक्ष…

2 days ago

Relativistic Electrodynamics in hindi आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा

आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा Relativistic Electrodynamics in hindi ? अध्याय : आपेक्षिकीय विद्युतगतिकी…

4 days ago

pair production in hindi formula definition युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए

युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए pair production in hindi formula…

6 days ago

THRESHOLD REACTION ENERGY in hindi देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा

देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा THRESHOLD REACTION ENERGY in hindi…

6 days ago

elastic collision of two particles in hindi definition formula दो कणों की अप्रत्यास्थ टक्कर क्या है

दो कणों की अप्रत्यास्थ टक्कर क्या है elastic collision of two particles in hindi definition…

6 days 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