undefined

I am newbie to C++ and am trying to teach myself to program. Could someone please explain in very simple language what data validation means and how should I check for it (in relation to input data) before any processing occurs.

:-| Merlin208

Let's say you want an interactive program to input two numbers, add them together, and display the result. The user types some text, right? Was that text actually representing a valid number? Or do you just blindly add two values that may or may not be there. Data validation, in the context I understand from your question, is merely making sure that the user actually entered two numbers before you try to add them.

When you explain your program, you make assumptions about what the data is. 'data validation' is when you test for those assumptions in your code.

"My program inputs an age, and I assume the age is between 10 and 100. Then I compute ...."

so, when you input the number that is supposed to be the age, you would verify that it is between 10 and 100 and if not, complain. THAT is data validation.

Dave said that too, I guess. :-)

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.