Purchase Solution

Using C printf Statement to Debug an application

Not what you're looking for?

Ask Custom Question

There are many ways to debug a program, perhaps the most elementary is using a printf() statement to show important pieces of information regarding the program execution point, variable value, and loop and branch operation.
The solution also answers the following questions.
How can you use the printf() statement?
Where will you place them?
How is it useful to use #define in aid of printf() debugging?

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 placec 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
Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Javscript Basics

Quiz on basics of javascript programming language.

Basic Networking Questions

This quiz consists of some basic networking questions.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.