Can anyone tell how really these functions work????

1.cin.ignore()
2.cin.clear()
3.cin.good()
4.cin.fail()
5.cin.bad()
6.cin.eof()

I mean to say what values these functions return at what situation...
thank you!

I also need to know about some user input validation techniques.i.e.
the user inputs valid data in the programs.....e.g.if there is some input
of date of birth the user enters only digits and in case of name the user
enters only characters etc.

Thank you once again....

Recommended Answers

All 3 Replies

Before inputing data you will be declaring the type of the data and so the compiler will give an error if you enter a different type eg,

int number;
cin>>number;

if you then enter an integer it will work but if you enter a character it wont similarily,

char initials;
cin>>initials; //the ">>" is an insertion operator

if you then enter a character it will work but not if you enter a number.
You always have to declare a variable before using it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.