C: simple print line seems to be changed by later command
John Kauffman
Posts: 653
I can't figure out why a print() result is different when it has/not a following command. Nothing else in the programs but frame of include, main, etc.
/*
Blank Simple Project.c
// !!! run either program #1 or program #2. REM out other.
*/
#include "simpletools.h" // Include simple tools
int main() // Main function
{
// Program #1
int a = 1, b = 2;
print("a = %d, b = %d\n", a); // error missing arg for second %d
/* display result:
a = 1, b = 1960 // as expected for the error: 1960
*/
/*
// Program #2
int a = 1, b = 2;
print("a = %d, b = %d\n", a); // error missing arg
print("a = %d, b = %d\n", a, b); // no error
/* display result:
a = 1, b = 0 // !!! why not 1960 like in program #1?
a = 1, b = 2
*/
}
/*
Blank Simple Project.c
// !!! run either program #1 or program #2. REM out other.
*/
#include "simpletools.h" // Include simple tools
int main() // Main function
{
// Program #1
int a = 1, b = 2;
print("a = %d, b = %d\n", a); // error missing arg for second %d
/* display result:
a = 1, b = 1960 // as expected for the error: 1960
*/
/*
// Program #2
int a = 1, b = 2;
print("a = %d, b = %d\n", a); // error missing arg
print("a = %d, b = %d\n", a, b); // no error
/* display result:
a = 1, b = 0 // !!! why not 1960 like in program #1?
a = 1, b = 2
*/
}
Comments