Data flow example

De Software testing
Ir para: navegação, pesquisa

Example 1

Consider the following source code extract:

main() {
	int x ;
	if (x==42) {. . .}
}

A common mistake is to reference the value of a variable x without first assigning a value to it.

References

  • <bib>vincenzi-maldonado:slides:2007</bib>


Example 2

Consider the following source code extract:

#include <stdio.h>

main() {
	int x;
	printf("%d", x);
}

Naive developers unconsciously assume that the language compiler or run-time system will set all variables to zero. What is the output of the program?


References

  • <bib>vincenzi-maldonado:slides:2007</bib>