Please explain...

Write your question here.

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
char pincode[7];
cout<<"\n Enter pincode";
cin.getline(pincode,7,'#');
cout<<"\n Pincode..";
cout.write(pincode,sizeof(pincode));
getch();
}


Pls explain how this program worked.

Just explain this two statement only

cin.getline(pincode,7,'#');

cout.write(pincode,sizeof(pincode));

how this line worked....
the reference section on this site is great for this kind of info

http://www.cplusplus.com/reference/istream/istream/getline/ shows the definition
istream& getline (char* s, streamsize n, char delim );
so pincode is the buffer, 7 is the streamsize (length of pincode) and # is the delimiter between numbers.

also

http://www.cplusplus.com/reference/ostream/ostream/write/?kw=cout.write shows the definition
ostream& write (const char* s, streamsize n);
so pincode is the buffer and sizeof(pincode) is the stream size.
Last edited on
Please explain what is the use of this line....

cin.getline(pincode,7,'#');

what is the use of delimeter?

cout.write(pincode,sizeof(pincode));
Topic archived. No new replies allowed.