According to Petzold:
printf("The sum of %i and %i is %i", 5, 3, 5+3);
and
char szBuffer[100];
sprintf(szBuffer, "The sum of %i and %i is %i", 5, 3, 5+3);
puts(szBuffer);
are functionally equivalent.
Consider this small c program:
/* lines3.c */
void main(void){
int x, y;
char szBuffer[100];
for (y =3D 1; y < 24; y++){
for (x =3D 1; x < 24; x++)
if ((x =3D=3D y || x =3D=3D 24 - y) && y !=3D 12){
// sprintf(szBuffer, "\xDB");
printf("\xDB");
// puts(szBuffer);
} else
printf("\xB0");
printf("\n");
}
return;
}
This is a command console application which makes a design when run. cl =
lines3.c should get the executable.
But if we uncomment the sprintf and puts statements and comment out the =
accompanying printf the result is very different.
So that tells me they are not functionally equivalent. What's the =
trouble here?
--=20
George Hester
_________________________________