Sample Program
On-Line Demonstrations of FlexeLint and PC-lint (aka FlexeLint for Windows)
Bug of the Month for June 2004
Bug of the Month Samples
Our programmer is printing a message using a function with a variable argument list but something is going awry. Can you spot the problem?
Modify this example, if desired, and then hit the Analyse Code button
#include
void print_out( char n, ... ) { if( n == 'i' ) printf( "%d", *(int *)(&n + 1) ); else if( n == 's' ) printf( "%s", *(char **)(&n + 1) ); } int main() { print_out( 's', "June hath " ); print_out( 'i', 30 ); print_out( 's', " days.\n" ); return 0; }
Run FlexeLint on Bug of the Month Samples
Home
|
Examples
|
Contact
|
Order
PC-lint and FlexeLint are trademarks of Gimpel Software
Copyright © 2009, Gimpel Software