Using the Print or printf Statement to Debug an Application
Not what you're looking for?
How would you use the print statement to debug an application? (Please provide a simple example).
Purchase this Solution
Solution Summary
A printf() statement can help you look deep into the action of a program. Although it is used to spot errors and faults but remember it is a non-interactive way of finding what is sometimes equivalent of a "needle in a haystack". In this solution you will learn three practical ways to debug an application illustrated with examples.
Solution Preview
A printf() statement can help you look deep into the action of a program. Although it is used to spot errors and faults but remember it is a non-interactive way of finding what is sometimes equivalent of a "needle in a haystack". I list some of the places you can insert a printf() for possible error checking:
1) Immediately after a scanf() to confirm the data you are reading conforms to the type and variable you as expected.
int main(){
int value;
printf("Please enter a value between 0 and 100");
scanf("%d", value);
/*inserting a printf() statement here ...
Purchase this Solution
Free BrainMass Quizzes
C# variables and classes
This quiz contains questions about C# classes and variables.
Word 2010: Table of Contents
Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.
Inserting and deleting in a linked list
This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.
C++ Operators
This quiz tests a student's knowledge about C++ operators.
Javscript Basics
Quiz on basics of javascript programming language.